Filter: Safe | Sun, May 31, 11:09 PM CDT

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Lobo3433, Staff Forum Coordinators: Anim8dtoon

Poser Python Scripting F.A.Q (Last Updated: 2026 Apr 22 10:09 am)

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: Simple code that works in normal script causing parser error in callback


3dcheapskate ( ) posted Sat, 25 September 2021 at 2:27 AM · edited Fri, 29 May 2026 at 5:33 AM

(Note: This is a follow-on from my adp001's suggestion to use Python in my "Creating a new master parameter that works modulo 360 - can it be done ?" thread and my subsequent "kValueOpTypeCodePYTHONCALLBACK doesn't seem to work" thread)

I realized that if I can't do the modulo 360 bit using valueOps, and have to resort to Python, then why not forget about doing the other maths using valueOps and do everything in Python ?

As a test I just tried to set a random x translation in a callback, but although the three lines work okay in the non-callback part of the script they cause a parser error in the callback.

FTtmuHohzQT966Lk4TnH4euBj9OGW2PBaDn2PA2C.png

(also, when I added the "import random" I realized that this script worked without the "import poser" which I understood was wessential for using any of the PoserPython calls)


The 3Dcheapskate (also available in DAZ and HiveWire3D flavours) occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.




3dcheapskate ( ) posted Sat, 25 September 2021 at 2:52 AM · edited Sat, 25 September 2021 at 2:56 AM

I've noticed that the Poser 11 sample callback "randomHeadVerts.py" (under C:\Program Files\Poser Software\Poser 11\Runtime\Python\poserScripts\SampleCallbacks) creates its own list of 1000 random numbers first because it says random.random() seems slow, but that wouldn't have anything to do with the parser error I'm seeing, would it ?

I also noticed that I'm setting the callback on xTran and explicitly changing xTran in the callback before returning the original value of xTran, which doesn't make a lot of sense - but again, that wouldn't be causing the parser error problem I see.

I've tried setting the callback on a different parameter, and using an explicit floating point value instead of random(), but the problem's the same.


The 3Dcheapskate (also available in DAZ and HiveWire3D flavours) occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.




adp001 ( ) posted Sat, 25 September 2021 at 3:17 AM

You return "parm" as a result of the function. But "parm" is not a floating point value. "parm" is the parameter object that has generated the event. "value" is the floating point value you may manipulate and return as new value to display.

The wired error message is a result of the code that called your function. Probably that is a Python function by itself.




3dcheapskate ( ) posted Sat, 25 September 2021 at 5:26 AM · edited Sat, 25 September 2021 at 5:27 AM

🤦

I think my brain is trying to tell me that it's no longer going to cooperate with me, and will do everything in its power to make me look foolish ! :)

(and I'd forgotten that when the computer tells me what the problem is, that's often designed specifically to mislead me :)


The 3Dcheapskate (also available in DAZ and HiveWire3D flavours) occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.




adp001 ( ) posted Sat, 25 September 2021 at 6:32 AM
3dcheapskate posted at 5:26 AM Sat, 25 September 2021 - #4428035

🤦

I think my brain is trying to tell me that it's no longer going to cooperate with me, and will do everything in its power to make me look foolish ! :)



:) :) :)




3dcheapskate ( ) posted Sat, 25 September 2021 at 10:52 AM · edited Sat, 25 September 2021 at 10:54 AM

Okay, I've tried again.

Am I missing something obvious here ?

The following script should, I believe, cause myUpdateCallback() to be called any time that the xTran dial on the BODY is changed, which will in turn cause the yRotate dial on the BODY parameter to be incremented.

However, if I change the xTran dial the yRotate value actually increases by between 3 and 5, which indicates to me that the callback is called that many times.

In addition, the same thing happens if I change yTran, zTran, xRotate, zRotate, Scale, etc. This script works on just about any figure - I tested it with La Femme.

1m1nZnEPw2QdxIACmVgZNm3uyuxinQEaoFMXBlRY.png

The same code as inline text:

def myUpdateCallback(parm,value):

ac = poser.Scene().ActorByInternalName("BODY")

yrotval=ac.Parameter("yRotate").Value()

ac.SetParameter("yRotate",yrotval+1)

return value

#

def setup():

print "setup()..."

ac = poser.Scene().ActorByInternalName("BODY")

parm = ac.Parameter("xTran")

parm.SetUpdateCallback(myUpdateCallback)

print "...done."

setup()



The 3Dcheapskate (also available in DAZ and HiveWire3D flavours) occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.




3dcheapskate ( ) posted Sat, 25 September 2021 at 10:35 PM · edited Sat, 25 September 2021 at 10:36 PM

New thread created for that last post...


The 3Dcheapskate (also available in DAZ and HiveWire3D flavours) occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.




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.