Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)
This may help.
http://www.philc.net/forum/viewtopic.php?t=2572
You just need to add a "for file in directory" loop
See the "walk" and "visit" sections in Poser 7RuntimePythonposerScriptsscripsMenuUtilityuncompressPoserFiles.py
I will try to put something together for you.
set render options
get folder name
get file list for folder
for each file in list
load file
render file
save render to same folder
with some tests to check if render completed ok.
I dont think you can error trap the render if files are not found but I will check
Python is indent sensitive , it uses indentation to determine what code is to be executed.
Theres some good introductory stuff on the python.org website.
This gets pz3 file names from ONE folder thats coded in the script
and renders using P4 renderer to image size also coded in the script.
Saved as a png file in the same folder with same name as the scene file.
You should be able to make the needed changes , just observe the format I used for the path.
Quote - I will try to put something together for you.
Python is indent sensitive , it uses indentation to determine what code is to be executed.
Thanks for your help.
indent sensitive?! Really ?
In VB indents (and caps) are just a user convenience. They have no effect in code.
(I am so never going to learn this language.)
thanks again
z
Quote - (I am so never going to learn this language.)
Learing Python (the language) is easy.
Learning to use Python as implemented in another program depends on how the creators chose to do the integration.
The best way to get used to the indentation thing is to use a Python aware editor, such as idle, which comes with the standard Python distribution.
Quote - crude batch render script attached.
This gets pz3 file names from ONE folder thats coded in the script
and renders using P4 renderer to image size also coded in the script.
Saved as a png file in the same folder with same name as the scene file.
You should be able to make the needed changes , just observe the format I used for the path.
Thanks man that script is almost perfect. I’ve been trying it out.
A few things though:
If there’s already a PNG file, it will overwrite it. That’s a problem because I’ve already manually done about half the icons. (so it either needs to take a file list, or skip Pz3s if it finds PNGs)
I keep getting a “Poser is out of memory” message, but then it seems to work anyway.
If it can’t find a PSD file, it renders a big solid colored square (way bigger than 91x91) (and the other missing files are a pain)
And (proudly) I’ve been able to make some changes myself: it takes soo long to load all the textures, it might as well do a Firefly render. And I changed the size to 300 square,too
Thanks again
z
indeed yes, the check for existing file is easy enough to add but the rest of it as far as I know cant be trapped. There is a close document at the end which is an attempt to get Poser to discard textures and clear some memory though I dont know if its working.
This is just my typical brute force programming :)
Quote - Have a look at this one. It should test for the output render name and skip the file if it exists.
its a simple if not os.path.exists(filename): test but you then have to indent everything thats dependant on the condition.
Um, I see the if not statement...
if not os.path.exists(cfo):
but it's still overwriting files, how is that?
I can make a list of the right files
maybe just hardcoding the filepaths would be easier
z
Hi everyone,
Ben Margolis here, from Rocketship Software, makers of PzDB.
I’ve been watching this thread because we have had several requests to have PzDB index Pz3 files too. And if we’re going to do that, we’re going to need something very much like this script.
So Z, I’ve found the bug you found in that If statement. (he forgot to add the file path to the name)
So that line should be:
if not os.path.exists(myfilepath + cfo):
And as you requested here’s a version that lets you enter any list of files, instead of doing whole directories:
import poser
import os
myq = []
myq.append ("E:PoserFilesCharactersDaveX1File1.pz3")
myq.append ("E:PoserFilesCharactersDaveX1File2.pz3")
myq.append ("E:PoserFilesCharactersDaveNew FolderFile3.pz3")
#add more files here
**
**#and then render them all
mql = len(myq)print "Rendering a possible " + str(mql) + " pz3 files."
for cf in myq:
cfo = cf[0:-4] + ".png"
cfd = cf
if not os.path.exists(cfo):
# open the scene file
print "Processing File: " + cfd
poser.OpenDocument(cfd)
# get the scene and set render type , output size
scn = poser.Scene()
scn.SetCurrentRenderEngine(poser.kRenderEngineCodeFIREFLY)
scn.SetOutputRes(300,300)
scn.SetFrame(0)
# render the scene
print "Rendering: "+ cfd
prr = scn.Render()
print prr
# save the image , same path, as png
print "Saving image as: " + cfo
scn.SaveImage("png", cfo )
# and close the document
poser.CloseDocument(1)
print "done"
markschum, If you wouldn’t mind I’d like to use this as a starting point for a Script that we include in the next PzdDB. It’ll need better error handling though, and I’d love a GUI window with a cancel button, any idea about how to do that?
Ben Margolis
Rocketship Software
Sure, use what you like. I dont do any commercial python work so I have no need to protect my stuff. I would be peeved if someone took a script and sold it without changes but to be commercial you need lots of error trapping. There are some dialog options in poser 7 and maybe 6 , otherwise you need to use tkinter which is just nasty in my limited experiance. ;)
There are several python guys who could do this easily, maybe one of them would be interested in a collaboration.
Just a point but the character in a string indicates a control character and will usually blow up. Best to use / or in path names.
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
I can’t be the first guy to want this:
I want to be able to render PNG thumbnails for PZ3 scene files, en masse. I have D3D’s batch render script and its close but, here’s what I need:
to be able to open a Pz3 file (preferably from an external list of filenames).
Set the rendersize to 91x91
Do a down and dirty P4 (non firefly) render, and save it (same path, same name .png)
Then go to the next file.
Seems pretty simple. One other thing, I’d love it to be fault tolerant. If it finds a missing object or texture, it should just skip it and render what it can find.
Does this (or something like it) exist somewhere?
I’m VB coder and not a Python coder, but if I saw the right examples I could probably cut and paste something together. The D3D “Render Scene” script opens and saves, but it only renders in firefly, and I have no idea how to set rendersize.
Aha tia
z