Tue, Nov 19, 7:31 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 Sep 18 2:50 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: Additive prop poses in python?


maclean ( ) posted Fri, 05 August 2011 at 10:17 AM · edited Mon, 18 November 2024 at 4:03 PM

I've searched this forum back to 2004, but can't find an answer.

Problem - I'm making a corridor kit (mostly props) in which pieces need to be moved in increments of 600cm and/or rotated +/- 90 degrees. The problem is that normal pose files are no good because I need the pieces to move 600cm each time the pose is applied (additive) - rather than have them simply moved to that position.

 

The Daz Studio version uses a set of simple pose scripts for this, but I imagine this can only be done in Poser through python. However, Ockham made a python dialog for me several years ago with a 'Jump' function, so I know it can be done. What I don't know is how to generate a script which can be applied to any prop, BODY or body part with this Jump in it. I also know I can use a .pz2 to call the python script, and that would probably be the best way for the user, rather than have them open the scripts.

 

Can anyone help out here? A free copy of the product is yours, when it comes out later this month.

 

TIA

 

mac


maclean ( ) posted Fri, 05 August 2011 at 11:16 AM

Hmm... I can get this to work, but it's not additive. When I apply it a second time, nothing happens, so it's just applying pose values.

import poser
scene = poser.Scene()
JumpSize=0.6971784 # in PU

actor= poser.Scene().CurrentActor()
actor.ParameterByCode(poser.kParmCodeXTRAN).SetValue(+JumpSize)
actor.ParameterByCode(poser.kParmCodeYTRAN).SetValue(-JumpSize)
actor.ParameterByCode(poser.kParmCodeZTRAN).SetValue(0)
poser.Scene().DrawAll()

mac


Dizzi ( ) posted Fri, 05 August 2011 at 12:24 PM

You're just setting the value, you need to add it to the current value like this:

param=actor.ParameterByCode(poser.kParmCodeXTRAN)

param.SetValue(param.Value+JumpSize) 

 

For anyone with Poser 8 or later, my WheelPosing script is probably easier for positioning many walls to form a corridor.



EnglishBob ( ) posted Fri, 05 August 2011 at 12:25 PM

You need to read the current value, then add (or subtract, depending) your jump value. I have some code that might be in the right ball-park, I think. I'll rummage in the attic and see what I can find, if nobody chips in meanwhile.


EnglishBob ( ) posted Fri, 05 August 2011 at 12:26 PM

What Dizzi said. :-)


PhilC ( ) posted Fri, 05 August 2011 at 1:23 PM

Or reset the dial sensitivity so that it "jumps" by the value you require.


maclean ( ) posted Fri, 05 August 2011 at 3:21 PM

Thanks for replying everyone. I now have this.

 


import poser
scene = poser.Scene()
JumpSize=0.6971784 # in PU

actor= poser.Scene().CurrentActor()
param=actor.ParameterByCode(poser.kParmCodeXTRAN)
param.SetValue(param.Value+JumpSize)
param=actor.ParameterByCode(poser.kParmCodeYTRAN)
param.SetValue(param.Value+JumpSize)
param=actor.ParameterByCode(poser.kParmCodeZTRAN)
param.SetValue(param.Value+JumpSize)
poser.Scene().DrawAll()


 

Which gives me this error message.

 

Traceback (most recent call last):
  File "", line 7, in ?
TypeError: unsupported operand types for +: 'builtin_function_or_method' and 'float

 

Line 7 is 'param.SetValue(param.Value+JumpSize) '

 

Have I got this right or not?

 

mac


Dizzi ( ) posted Fri, 05 August 2011 at 3:34 PM

Needs to be param.Value()

No idea how the brackets got lost 



maclean ( ) posted Fri, 05 August 2011 at 3:44 PM

Yeeeeeeeeeeehaaaaaaaaaawwwwwwwwwwwww!!!!!!!

 

That did it!!

 

Thanks so much, Dizzi. I'm PM-ing you now.

 

mac


maclean ( ) posted Fri, 05 August 2011 at 3:57 PM · edited Fri, 05 August 2011 at 3:59 PM

In case anyone else might need this in future, here's my final code including rotations. Tested and working.

X channels - positive value

Y channels - negative value

Z channels - no change

JumpSize = 0.6971784 or 170cm - change value to suit.

 


import poser
scene = poser.Scene()
JumpSize=0.6971784 # in PU
RotValue=90

actor= poser.Scene().CurrentActor()
param=actor.ParameterByCode(poser.kParmCodeXTRAN)
param.SetValue(param.Value()+JumpSize)
param=actor.ParameterByCode(poser.kParmCodeYTRAN)
param.SetValue(param.Value()-JumpSize)
param=actor.ParameterByCode(poser.kParmCodeZTRAN)
param.SetValue(param.Value())
param=actor.ParameterByCode(poser.kParmCodeXROT)
param.SetValue(param.Value()+RotValue)
param=actor.ParameterByCode(poser.kParmCodeYROT)
param.SetValue(param.Value()-RotValue)
param=actor.ParameterByCode(poser.kParmCodeZROT)
param.SetValue(param.Value())
poser.Scene().DrawAll()


 

Thanks again to everyone!

 

mac


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.