Thu, Nov 7, 8:50 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: Script help


Uncanny_Film ( ) posted Mon, 21 August 2023 at 10:54 AM · edited Thu, 07 November 2024 at 6:15 AM

Hi, I'm trying to learn code. And I wanted to create a poser script. I tried to make a simple zero transition script. But I got this error message:

Traceback (most recent call last):

  File "C:\Users\spart\Documents\1.py", line 18, in <module>

    set_rotation_axes_to_zero()

  File "C:\Users\spart\Documents\1.py", line 9, in set_rotation_axes_to_zero

    current_selection.SetXRotation(0)

AttributeError: 'poser.ActorType' object has no attribute 'SetXRotation'




What am I doing wrong? Thanks

Here's my code:




import poser


def set_rotation_axes_to_zero():

    # Get the currently selected object in Poser

    current_selection = poser.Scene().CurrentActor() or poser.Scene().CurrentProp()


    if current_selection is not None:

        # Set X, Y, and Z rotations to zero

        current_selection.SetXRotation(0)

        current_selection.SetYRotation(0)

        current_selection.SetZRotation(0)


        print("Rotation axes set to zero for the selected object.")

    else:

        print("No object selected.")


# Call the function to set rotation axes to zero

set_rotation_axes_to_zero()







Win10 - AMD 2nd Gen Ryzen Threadripper 2950X, 16-Core, 32 Thread 4.4 GHz - 128GB Ram - X2 GeForce RTX 3060 Ti - 3D-connexion  

Poser 12 | Octane Render |  Real-Flow | 3DCoat | Speed Tree | Adobe Premiere  |  Adobe After Effects |  Adobe Audition |  Adobe Photoshop


HartyBart ( ) posted Tue, 22 August 2023 at 1:21 PM

Here's a 'most simple' script to zero the rotations on the currently selected/active prop or figure, which may be of use.


# Zero the rotation of the currently selected prop or figure in Poser. Works in P11 or P12.

import poser

scene = poser.Scene()

actor = scene.CurrentActor()

actor.ParameterByCode(poser.kParmCodeXROT).SetValue(0.0)

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

actor.ParameterByCode(poser.kParmCodeZROT).SetValue(0.0)

# Redraw the OpenGL Preview viewport in Poser, so we can see what's been done.
scene.DrawAll()




Learn the Secrets of Poser 11 and Line-art Filters.


Uncanny_Film ( ) posted Wed, 23 August 2023 at 3:13 PM

HartyBart posted at 1:21 PM Tue, 22 August 2023 - #4473228

Here's a 'most simple' script to zero the rotations on the currently selected/active prop or figure, which may be of use.


# Zero the rotation of the currently selected prop or figure in Poser. Works in P11 or P12.

import poser

scene = poser.Scene()

actor = scene.CurrentActor()

actor.ParameterByCode(poser.kParmCodeXROT).SetValue(0.0)

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

actor.ParameterByCode(poser.kParmCodeZROT).SetValue(0.0)

# Redraw the OpenGL Preview viewport in Poser, so we can see what's been done.
scene.DrawAll()


Thanks,

Also, here's a code that I came up with. To set X Tran to 1.

How can I alter this code to change the transitions +1 unit every time I activate this script?

Thanks


import poser


scene.CurrentActor().ParameterByCode(poser.kParmCodeXTRAN).SetValue(1)


scene.DrawAll()






Win10 - AMD 2nd Gen Ryzen Threadripper 2950X, 16-Core, 32 Thread 4.4 GHz - 128GB Ram - X2 GeForce RTX 3060 Ti - 3D-connexion  

Poser 12 | Octane Render |  Real-Flow | 3DCoat | Speed Tree | Adobe Premiere  |  Adobe After Effects |  Adobe Audition |  Adobe Photoshop


HartyBart ( ) posted Wed, 23 August 2023 at 5:20 PM

Ah, I see. Here it seems you're trying to do a 360-degree spin-around animation on the X axis? We'll there's my paid-for script in the Store, which gets you an animated 360-degree turnaround animation.

But the basic 'increment a value by one' script for Poser would be...


import poser

scene = poser.Scene()

actor = scene.CurrentActor()

# Capture the number on the actor's X-rotation dial.
value = actor.ParameterByCode(poser.kParmCodeXROT).Value()

# Take this newly found number and increment it by one.
value += 1

# Now set this new incremented number on the actor's X-rotation dial
actor.ParameterByCode(poser.kParmCodeXROT).SetValue(value)

# Redraw the OpenGL Preview viewport, so we can see what's changed.
scene.DrawAll()



Learn the Secrets of Poser 11 and Line-art Filters.


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.