Poser Python tutorial?
eclark1849 last edited by eclark1849
I'll make this quick... any chance of someone making a quick tutorial of how to write a Python program for Poser for a beginner like me? I'm not looking for anything elaborate. Maybe something like make a clock or how to turn off and on a Poser light. Load Poser cube or figure. etc.etc. I need something Poser oriented that I can learn from without it being too difficult.
ghostship last edited by
I don't program but here is a good link:
structure last edited by structure
scene = poser.Scene()
for light in scene.Lights():
if light.LightOn(): light.SetLightOn(0) # Turn light off else: light.SetLightOn(1) # Turn Light on
Y-Phil last edited by Y-Phil
Example to help finding an object in the hierarchy (can be tedious, depending on the number of sub-items...)
Open the hierarchy window, select an item from which the search will be done, and run the script you will find here.
Reading existing simple python scripts is a good start.
There is a python manual that comes with Poser, or at least it did with P10/2014. You might also check out PhilC's site for an extensive lesson manual he created. I bought it a year or two ago but haven't worked my way through it yet.
aldrinjohn last edited by
Check this...Python Tutorial
anomalaus last edited by
@eclark1849 something I fall back on constantly with Python syntax and usage is to just type in my browser search bar "python <thing-i'm-looking-for>" there are huge volumes of discussions on Stack Overflow which are very helpful, and the syntax definitions for Python are all online, so I rarely find myself stuck, unless it's something to do with an algorithm or math problem that's not directly python related.
The risk with asking for a non-specific tutorial is getting RTFM type answers. It's a lot easier to provide specific answers to specific questions, but, never be afraid to ask. :-)
Poser also has some bundled Python scripts in poser.AppLocation()/Runtime/Python/poserScripts/
some of the geometry related scripts are especially revealing for how Poser deals with meshes and vertices.
The Python Shell within Poser is a great playground for testing out bits of script, and supports command completion for defined identifiers. Just remember to make lots of shortcut definitions like:
scene = poser.Scene()
to save lots of repetitive typing. When I'm doing lots of nested loops, like traversing the nodes of a material/layer/shadertree, I'll build up the known states by throwing in dummy "pass" statements, inside the inner loop, to give the shell a chance to populate it's known identifier lists, so that command completion can work:
actor = scene.CurrentActor() for mat in actor.Materials(): pass
If I try to put the inner loop in immediately, I'll find that until I've executed the block of code which will assign a value to the variable "mat", I won't get the command completion popup when I type "mat." (mat-dot), to show me what methods and attributes the "mat" object has.
Next step, I can go a bit further, and don't have to define "actor" again:
for mat in actor.Materials(): for layer in mat.Layers(): # Now command completion will show me that mat has a method "Layers" tree = layer.ShaderTree() # But so far, cmd completion couldn't tell me layer has a "ShaderTree" method ...