Thu, Jan 9, 9:48 AM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Running a python script from a cr2 or pz3


face_off ( ) posted Mon, 20 December 2004 at 6:45 PM · edited Thu, 09 January 2025 at 9:35 AM

Hi All Just wondering if anyone had ever found a way to execute a python script from within a pz2, pz3 or cr2 file (ie. when you load the file, it fires off the script)? I assume it's not possible, but thought I ask anyway.

Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook


Helgard ( ) posted Mon, 20 December 2004 at 9:20 PM

.


Your specialist military, sci-fi, historical and real world site.


ockham ( ) posted Mon, 20 December 2004 at 10:00 PM

It's easy within a CR2 or PP2. Just add a pythonStartupScript line. Note that the line goes just after the figure-type stuff and before the materials section in a CR2. You will need to experiment some, because the exact timing of the call makes some actions impossible. I don't recall the specifics, but I tried it once and decided it wouldn't work for my purpose because the call seemed to happen before the CR2 was all done loading. You might try putting the call at the very end of the file? ........... origFigureType 1318 canonType 8 conforming 0 pythonStartupScript 0 0 ":Runtime:python:abcde.py" material Skin { KdColor 1 0.790311 0.660014 1 KaColor 0 0 0 1 etc

My python page
My ShareCG freebies


face_off ( ) posted Mon, 20 December 2004 at 10:05 PM

Ockham......Fan-tastic. Thank you!!!!! You are a champion.

Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook


ockham ( ) posted Mon, 20 December 2004 at 10:14 PM

PS: I just tried the experiment (again, probably) and found that the line definitely has to be in that location. It won't run at the very end of the CR2. In a PZ3 it goes at the very end of the Doc section: ......... TwoPortsTopBottom_p2 MAIN_CAMERA pythonStartupScript 0 0 ":Runtime:Python:poo.py" } illustrationParms { combineGradient 0 etc............ I can't seem to make it work in a PZ2, though.

My python page
My ShareCG freebies


face_off ( ) posted Mon, 20 December 2004 at 10:31 PM

Mmmmm, I also just tried it in a pz2 file - the Pz2 loads ok, but the python script gets ignored.

Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook


ockham ( ) posted Mon, 20 December 2004 at 10:39 PM

Yup, that's what it seemed to do for me. Most of the stuff that normally goes in a PZ3 can be "trojanned" by a PZ2, but this must be one of the exceptions.

My python page
My ShareCG freebies


face_off ( ) posted Mon, 20 December 2004 at 11:27 PM

Bummer. Would be awesome to be able to fire off python scripts via a pose, rather than the buggy python window.

Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook


ockham ( ) posted Mon, 20 December 2004 at 11:33 PM

Bit more experimenting. It is possible; I took a simple PZ3 containing the line, renamed it to PZ2, and loaded it as a Pose. The script took effect. So it's just a question of finding how much of the PZ3 stuff has to be there....

My python page
My ShareCG freebies


face_off ( ) posted Mon, 20 December 2004 at 11:47 PM

Well it seems to need more than just a version and doc command....will try adding stuff...

Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook


ockham ( ) posted Mon, 20 December 2004 at 11:48 PM

Yeah, it's weird. Somewhere between a full PZ3 and the bare minimum is a key of some kind. I haven't found it yet.

My python page
My ShareCG freebies


face_off ( ) posted Mon, 20 December 2004 at 11:53 PM

I've adding everything but the figure - and no go. Maybe the trigger could be when it actually loads a new figure.

Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook


ockham ( ) posted Mon, 20 December 2004 at 11:58 PM

That's probably the point. My sample PZ3 does include a real figure. In that case the PZ2 wouldn't be useful anyway; might just as well use a CR2!

My python page
My ShareCG freebies


face_off ( ) posted Tue, 21 December 2004 at 12:17 AM

Yes - I guess the real downside is that you can't run a python script for an existing character - only a new one via a cr2.

Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook


Helgard ( ) posted Tue, 21 December 2004 at 2:18 AM

Ockham, does this mean that when I release the nextgen figures, we can have the naturalizer and jiggles combined script load automatically with the figure, so the customer doesn't have to actually do anything? This is really going to give EAP a kickstart. I still can't get the animated pose file to load properly with a CR2. Anybody know how to do this?


Your specialist military, sci-fi, historical and real world site.


ockham ( ) posted Tue, 21 December 2004 at 12:48 PM

Yes, it does. Running from CR2 is definitely possible. Which animated pose file?

My python page
My ShareCG freebies


Helgard ( ) posted Tue, 21 December 2004 at 5:59 PM

Ockham, I am trying to make a system that is easier for people to use. Example: I have a room, with ceiling fans. I have an animated pose file that rotates the fans, say a 200 frame animated pose file. When the customer loads the CR2 of the room, I want the animated pose file to load as well. So all the customer has to do is load his characters, animate them, and render. The "automatic" animations, like the fans turning that are tedious to animate, is done for him already. I must be doing something wrong, because it keeps messing up and I can't get it to work.


Your specialist military, sci-fi, historical and real world site.


PoseWorks ( ) posted Tue, 21 December 2004 at 9:45 PM

Attached Link: http://wooyah.com/ubbt/prod/showflat.php?Cat=&Number=7028&page=0&view=collapsed&sb=5&o=&fpart=1

Ockham, I posted a technique on Wooyah.com's forums about using hacked CR2 files to load python scripts rather than relying on the scripts window. I played with library-loaded Python quite a bit working on Particles 2 [shameless plug]due out January from DAZ [/shameless plug] and this was the best method I found. Interesting side note: Poser does apply pythonStartupScript lines from PZ2's to the current figure, it just doesn't execute them like it does when loading CR2s and PZ3s. I attempted to splice doc pystart lines into CM2 and LT2 files as well, with little success.


face_off ( ) posted Wed, 22 December 2004 at 2:44 AM

Hi Poseworks - this is awesome. I'm not sure what you mean by "does apply pythonStartupScript lines from PZ2's to the current figure, it just doesn't execute them like it does when loading CR2s and PZ3s". I found that it parsed the line, but didn't execute the script. Maybe I was doing something wrong. I tried your cr2 method. Very interesting. If you Replace the current figure with the script (ie. double-click the icon) - your figure gets removed from the scene and then the script runs. But if you select the script in the character list, and click the Create New Figure button - it adds a new figure (called PyTrojanFig - from your cr2) and runs the script - and leaves the PyTrojan in the scene. I need to play with this some more I think....

Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook


stewer ( ) posted Wed, 22 December 2004 at 6:54 AM

You may want to have a look at the Barney cartoon figure that comes with ProPack and P5, it has a small Python script attached to it.


face_off ( ) posted Wed, 22 December 2004 at 2:09 PM

I guess a way of handling the "PyTrojan" being left in the scene would be to have the script delete it! The issue I've got is that I need to have a figure selected when I run the script. Having the script fire-off from a .cr2 file results in a new figure being created, so the original selected figure is no longer current. That's why I was heading down the "run the script from a pz2 file" path.

Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook


ockham ( ) posted Wed, 22 December 2004 at 2:37 PM

Interesting technique! Not sure that it would be worthwhile for simple actions; deleting takes noticeable time and sometimes leaves odd stuff behind. But for a script that's going to do serious work anyway, this would be worth the trouble.

My python page
My ShareCG freebies


Lucifer_The_Dark ( ) posted Thu, 23 December 2004 at 1:35 PM

couldn't you create a dummy .cr2 or .pp2 file that automatically parents to the original figure while loading the script? something like the fix for crosstalk in poser4 where you loaded a null figure between 2 characters as a barrier between them.

Windows 7 64Bit
Poser Pro 2010 SR1


face_off ( ) posted Thu, 23 December 2004 at 3:44 PM

LtD, now THAT'S an idea. Not sure how to autoparent in a cr2 though. Do you know of any tutorial's on this?

Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook


PoseWorks ( ) posted Thu, 23 December 2004 at 10:58 PM

Face_off--be sure to use a "caller" script like the one described in the WooYah thread to kill the PyTrojan figure and then process its deletion. Ockham--I've noticed that the interface will cling to remnants of PyTrojanFig, but as long as you have the script process a Poser event after deletion, there should be no trace of the PyTrojanFig after your script is done running. What artifacts/messiness have you encountered? LtD--Could you describe this technique some more? It sounds promising.


underdog ( ) posted Sun, 26 December 2004 at 6:04 PM

Wow! You all are FANTASTIC. I wanted to do this about a year or so ago and gave up. I wandered in here looking for osmething else (if I don't find it I will post a question in another message) and found this jewel waiting for me. THANKS!


Privacy Notice

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.