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


HartyBart posted Tue, 08 December 2020 at 8:43 PM

"It would be great to save the image with the same name of the current Poser file"

Good idea.

One way to do such a task would be to have the script output your preview.PNG, firefly.PNG, sketch.PNG, etc, to one standard location such as a "my_new_renders" folder. No complex re-naming or manual editing is then required within the script. Then at the same time you could have the script save the Poser scene file by using poser.SaveDocument command, where the Methods Manual states "If you do not specify an argument, the file will be saved in its current path with its current name."

After running the script you would thus end up with a folder with....

scene001.PZ3

sketch.PNG

firefly.PNG

preview.PNG

Then you'd have a macro watching that folder and auto-renaming PNG files as they arrived, according to a file mask taken from the last-saved PZ3 filename in the folder. Thus any sketch.PNG would automatically become scene001_sketch_001.PNG and so on. Then you would be safe to run the script again, knowing that the next saves would become scene001_sketch_002.PNG and so on.

The problem there is if you are then planning to combine your renders with a Photoshop Action that loads and juggles named files, and as such cannot cope with any filename iteration. The Action expects, every time, to load...

sketch.PNG

firefly.PNG

preview.PNG

... and then to name layers accordingly.

In which case it's not the files but their folder that must be re-named, to something like my_new_renders_scenename_renders001. To do this a macro would be watching the save folder, do the rename according to the name of the PZ3 found in the folder, and would then create a fresh my_new_renders folder - ready to receive the script's next batch of renders. On future runs the macro would know to increment the new folder name, from my_new_renders_scenename_renders001 to my_new_renders_scenename_renders002 and so on.

This would require a lot of hard-drive space, since each time you're saving a new .PZ3 so as to get the scene filename, but if you're doing that kind of production then you have that kind of space.

Perhaps all this could be done in Python via using methods such as os.rename and os.path.exists and fileName.split and suchlike - but I'm not sure if PoserPython can do that or if Poser would be allowed to do such things at the file/folder level by the OS. Another way might to have the end of a Python script call a BAT file, but I've no idea how to do that either. Can PoserPython call and run BATs?



Learn the Secrets of Poser 11 and Line-art Filters.