Fri, Mar 29, 3:10 AM CDT

Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Mar 19 1:03 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: How to force selection of "Figure | Body"?


HartyBart ( ) posted Sat, 10 July 2021 at 8:43 AM · edited Thu, 28 March 2024 at 7:06 AM

I have a figure in Poser, and the "Figure | Left Foot" item is currently selected.

How do I have a Python script change and set the current body-part selection to the root "Figure | Body"?

I thought I knew how to have a Python script do this, but it seems not. The code I was using was not giving errors, but was also not doing anything.



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


HartyBart ( ) posted Sat, 10 July 2021 at 11:09 AM

The following appears to work:

import poser
scene = poser.Scene()
figure = scene.CurrentFigure()
actor = scene.CurrentActor()

scene.SelectActor(figure.ParentActor()) 

The default ParentActor value in the () almost always being the figure's BODY, according to the Methods Manual ("the parent of a figure is typically the “Body” actor"). Am I doing it right?



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


structure ( ) posted Sat, 10 July 2021 at 6:36 PM
Forum Coordinator

I would use this

import poser
scene = poser.Scene()
figure = scene.CurrentFigure()
actor = figure.Actor("Body")

Locked Out


HartyBart ( ) posted Sun, 11 July 2021 at 1:33 AM

Thanks, yes, I tried that before ParentActor - but for some reason it would not work on my test figures. I had the error message that "Body" was not a findable name for the figure. My guess was then that not all figures have an explicit "Body" as a named item within them.



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


structure ( ) posted Sun, 11 July 2021 at 2:54 AM · edited Mon, 12 July 2021 at 3:54 PM
Forum Coordinator

also remember that there is no explicit naming convention used by modellers, so body could be also be

     1. UPPER-CASE
     2. lower-case
     3. MiXeD-CaSe

it may be easier to define a small function to test for that,

import re
class figureOps:
    def test_for_body( self, figure = None ): 
        if figure: 
            for actor in figure.Actors()
                if re.search('body', actor.Name(),  re.IGNORECASE):
                    return actor
        return None

bodyactor = figureOps().test_for_body( scene.CurrentFigure )
if bodyactor:
    scene.SelectActor( scene.Actor( bodyactor.Name() )
else:
    print( "'Body' does not exist on current figure" )

Locked Out


Y-Phil ( ) posted Sun, 11 July 2021 at 7:28 AM · edited Sun, 11 July 2021 at 7:29 AM

Someboy the actor often named "Body" can have another name. Try with its internal name, something that is rarely changed if I'm not wrong:

scene = poser.Scene()

# Retrieve the firgure itself
check = scene.CurrentActor().ItsFigure()

# Look for the BODY actor
body_parts = [actor for actor in check.Actors() if 'body:' in actor.InternalName().lower()]
if body_parts:
    scene.SelectActor(body_parts[0])

You may even select ifs hair props... ?

PhYl.


Win10 on i7 8700K@4.3Ghz, 64Gb, Asus TUF Gaming RTX 4070 OC Edition, 2x 2Tb ssd + 6+4Tb hd  + 1x 8Tb hd + 1 10T NAS, Poser 11, Poser 12  and now Poser 13 


adp001 ( ) posted Tue, 13 July 2021 at 2:50 AM

Try [actor].ItsFigure().RootActor()




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.