• Welcome to the Community Forums at HiveWire 3D! Please note that the user name you choose for our forum will be displayed to the public. Our store was closed as January 4, 2021. You can find HiveWire 3D and Lisa's Botanicals products, as well as many of our Contributing Artists, at Renderosity. This thread lists where many are now selling their products. Renderosity is generously putting products which were purchased at HiveWire 3D and are now sold at their store into customer accounts by gifting them. This is not an overnight process so please be patient, if you have already emailed them about this. If you have NOT emailed them, please see the 2nd post in this thread for instructions on what you need to do

Learning Poser Python...

phdubrov

Noteworthy
Contributing Artist
AFAIK, not in a straight way. All solutions that I saw used either temp matfile/posefile (Netherworks) or nodetree recreation (Snarlygribbly, BB). Or, as a variation of the former, template matfile, where the script reads it, insert/change image files references, and saves with another name. (Made such script for myself, helps a lot with flowers packages, when you have a lot of texture options.)

Had an intention to look at pickle way to do it, but still didn't. Had enough of Zope world before switched to Django.
 

Ken1171

Esteemed
Contributing Artist
It's not particularly difficult for me to recreate this specific shader in code (only 3 nodes), but I don't know how to make a compound node out of it. I know how to create a compound node, but not how add nodes into it, or plug the respective inputs and name them. In Poser, this is not how these are created. We first select the nodes we want to group, and then activate the grouping function. In PoserPython, there is a command to create compound node, but that's all it shows.

Any clues?
 

phdubrov

Noteworthy
Contributing Artist
Python Shell has autocompletion and tips IDE-style. So you can see methods of CompoundData object. Never used it, but looks it's like ShaderTree manipulations.

Add: played in the console, yes, works like a charm.
 
Last edited:

Ken1171

Esteemed
Contributing Artist
Oh, that's good to know. I am writing my classes on notepad, and having to restart Poser whenever I edit an imported class. Kind of a chore.
 

phdubrov

Noteworthy
Contributing Artist
Use reload. By the way, you probably can call reload from Python Shell. Should work. Commands history works with CTRL-UpArrow, by the way. Do not remember if docs says so.
 

Ken1171

Esteemed
Contributing Artist
What does it do? Reload all cached classes? Is it a language command or a shell command?
 

Ken1171

Esteemed
Contributing Artist
Not sure if it's just me, but that article offers not a single code example. Do I call this from the PY file that imports the class I want to reload? Or from the Python shell? Or from the class I have modified? Sorry, I am confused.
 

phdubrov

Noteworthy
Contributing Artist
from the PY file that imports the class

like this:

#dosomething.py
import donothing
reload(donothing)


my = donothing.MyClass()
my.f()

OR (possibly) from python shell in poser. Do not forget to destroy any instances of your class you created! Instances do not change with reload.
 

Ken1171

Esteemed
Contributing Artist
Aha! Nothing like a code example - worth a thousand words. Thanks!

I keep reading about instances not changing with reload, but I don't understand what that means. Once the program is closed, all instances go to garbage collection, and will be created again next time I run the program. I don't change classes that are still used by a running script. At least that's how I see it. Am I missing something?

Also, I am here trying to make sense of the Python Shell. It opens like a shell, but you've mentioned it being used like an IDE with code completion? How?
 

phdubrov

Noteworthy
Contributing Artist
Once the program is closed, all instances go to garbage collection
Once Poser is closed - yes. Once your script finished its works - dependent on your code scope structure.

So, if you do something like
First test run
a = mymodule.MyClassOldVerWithMethodA()

Second test run
reload(mymodule)
a = mymodule.MyClassNewVerWithMethodB()

probably both a.A() and a.B() could be defined. Or not. Grey zone. So better del a when the script is finished.

autocompletion - just try to start s = poser. - and here autocompletion will fire with methods and properties. Plus you will have a tip with method parameters once you choose a method.
 

Ken1171

Esteemed
Contributing Artist
Ooh, I see! I thought instances were killed by garbage collection once execution passes their last occurrence in code.
 

phdubrov

Noteworthy
Contributing Artist
It's right. But! We are in never-ending (until Poser quits) interactive session here. So all depends on the scope organization of the script.
 

Ken1171

Esteemed
Contributing Artist
Let's see, from the code below, is there something left after execution? As I see it, once main() finishes execution, wouldn't GC kill everything? There is no references left.

def main():
....import Foo
....o= Foo()
....0.doThis()
....o.doThat()

main()
 

Ken1171

Esteemed
Contributing Artist
Gotcha. Thank you! I managed to get everything I wanted done, to include creating compound nodes, GUIs, and file management. Only thing missing is to understand how events work in Python. That's my next thing. :)
 

Ken1171

Esteemed
Contributing Artist
This was the first time in YEARS since I have found Poser documentation this poorly written. In Esha's tutorial, she has also claimed PhilC's tutorial was outdated and some parts wont work in the current version. I was putting too much faith on it, and ended up learning more from my books instead. They are old, but they get to the point more quickly than his tutorial. Maybe because books tend to be more organized than tutorials, and also cover the subjects in more depth. PhilC was presenting many code listings, but he didn't explain what some commands actually did, so I was starting to feel sort of "cheated", if you know what I mean. The code listings just weren't working for me.
 
Top