Forum: Poser Python Scripting


Subject: Python can set a render-engine and render, but can it also call a preset?

HartyBart opened this issue on Dec 05, 2020 ยท 23 posts


adp001 posted Wed, 09 December 2020 at 3:57 AM

Nice how you solved the windowname grabbing with " - " :)

About drive letters: I have 4 of them with windows at the moment. Which one should I use now?

A sugestion: Use some sort of config file. It's pretty simple with a dictionary and Json.

Some snippets:

import os
import json
import time

Config = dict()
Config["mainpath"] = r"---------"
Config["finals"] = r"."
...
project_name, _, _ = wx.GetTopLevelWindows()[0].GetLabel().partition(" - ")
config_fname = "config_%s.cfg" % project_name

# write config.
with open(config_fname, "w") as fh:
    json.dump(Config, fh)

# read config
if os.isfile(config_fname):
    with open(config_fname, "r") as fh:
        Config = json.load(fh)

# save a render
render_engine = poser.Scene().CurrentRenderEngine()
render_engine_name = "SuperFly" if render_engine == poser.kRenderEngineCodeSUPERFLY 
    else "FireFly" if render_engine == poser.kRenderEngineCodeFIREFLY 
    else "Preview"

filepath = os.path.join(Config.get("mainpath", r"c:/"), project_name)
if not os.path.isdir(filepath):
    os.mkdir(filepath)
datetime = time.strftime("%d-%m-%Y/%H:%M", time.localtime())
filename = os.path.join(filepath, render_engine_name + datetime)

...