Thu, Jan 9, 4:11 PM CST

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Coordinators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2025 Jan 09 3:46 am)



Subject: Poser Python - Need Help Getting Started


TerriJohns ( ) posted Tue, 29 October 2013 at 1:33 PM · edited Thu, 09 January 2025 at 4:06 PM

I'm new to Poser Python. I am trying to perform a simple task - put a value into a figure's parameter (for example, bend the shin to a certain angle). But I keep getting an error message when I run my script. Can someone take a quick look and see if my syntax is incorrect?

My example:

import poser
import random
scene=poser.Scene()
scene.SetFrame(23)
scene.SelectFigure(scene.Figure('Roxie'))
actor = scene.Actor('Left Shin')
parm = actor.ParameterByCode(poser.ParmCodeBEND)
parm.SetValue(88)

 

When I run the above script, I get the following error:

Traceback (most recent call last):
*  File "C:UsersPublicDocumentsPoser Pro 2014 ContentMy Pythonkicking1.py", line 7, in *
*    parm = actor.ParameterByCode(poser.ParmCodeBEND)*
AttributeError: 'module' object has no attribute 'ParmCodeBEND'

 


Cage ( ) posted Tue, 29 October 2013 at 2:06 PM

I think you need to use a different parameter code.

kParmCodeXROT

kParmCodeYROT

kParmCodeZROT

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


TerriJohns ( ) posted Wed, 30 October 2013 at 9:47 AM

No dice, at least not yet. Altered the code to:

import poser
import random
scene=poser.Scene()
scene.SetFrame(23)
scene.SelectFigure(scene.Figure('Terri'))
actor = scene.Actor('Left Shin')
parm = actor.ParameterByCode(poser.kParmCodeBEND)
parm.SetValue(88)

but got the error -

 in
    parm = actor.ParameterByCode(poser.kParmCodeBEND)
AttributeError: 'module' object has no attribute 'kParmCodeBEND'

Aren't there some simple examples online? I've found a few sites claiming to be intros to Poser Python, but they are "Hello World" programs. I want to manipulate Poser, not figure out how to say "Hello World"  ;)


TerriJohns ( ) posted Wed, 30 October 2013 at 10:28 AM

My fault. Bend is not a valid code. YTRAN, ZTRAN and XTRAN are what I need to use. So the following code works -

import poser
import random
scene=poser.Scene()
scene.SetFrame(23)

MyFig = scene.Figure('Terri')
ChangeParm = MyFig.Actor("Left Shin").ParameterByCode(poser.kParmCodeYTRAN)
ChangeParm.SetValue(5)

I'm used to working with Bend values, so I just have to figure out appropriate YTRAN values instead. The next step is to add some randomness to the parameter changes to make movements look more natural.


stewer ( ) posted Wed, 30 October 2013 at 12:06 PM

Use the parm codes that Cage posted, those for rotation. YTRAN will translate the shin, not bend at the knee. 


Cage ( ) posted Wed, 30 October 2013 at 2:51 PM · edited Wed, 30 October 2013 at 2:51 PM

In the folder where you poser.exe is installed, there should be a PoserPython Methods Manual.pdf, which lists all of the parameter codes near the top.  Each listing has a short explanation of what function the code invokes.  The list isn't necessarily the easiest to scan quickly, but it can be very helpful.  After a bit of trial and error, it's fairly easy to pick up the process, and you're doing well so far.  :thumbupboth:

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


TerriJohns ( ) posted Thu, 31 October 2013 at 8:14 AM

Thank you Cage. So a Bend, Side to Side, or Twist is accomplished by the various rotations. That's helpful, thank you very much.

You are correct, the PDF is not easy to scan. :)


timarender ( ) posted Thu, 31 October 2013 at 10:49 AM

Instead of "parm = actor.ParameterByCode(poser.ParmCodeBEND)", I suspect this might work:

parm = actor.Parameter("Bend")


icprncss2 ( ) posted Thu, 31 October 2013 at 2:42 PM

PhilC has a very comprehensive pdf on Python.  You might want to take a look at it over at PhilC.net.


Allstereo ( ) posted Thu, 31 October 2013 at 10:00 PM

Hello,

Here is the code that I used to get the value and set the value of a parameter

#Define the actor

actor = scene.Actor("External name")

#Read value of actor

actor.ParameterByCode(poser.kParmCodeYROT).Value()

#Set value of actor to 80

actor.ParameterByCode(poser.kParmCodeYROT).SetValue(80)

 

Allstereo


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.