Forum: Poser Python Scripting


Subject: Is this the best way to select a prop with an unknown name?

HartyBart opened this issue on Aug 10, 2021 ยท 9 posts


structure posted Fri, 13 August 2021 at 4:26 AM Forum Coordinator

the following script will find the first valid actor and select that actor.

import poser

scene = poser.Scene()

class valid:

    def IsValid( self , actor , bodypart=False ): # a modified function of a Snarlygribbly routine

        if not actor is None:

            n       =   actor.Name().lower()

        if n.endswith("con") or n.endswith("con 1"):

            return False

        data    =   [

                    'atmosphere','background','bodymorphs','centerofmass',

                    'faceroom','focusdistancecontrol','ground','grouping',

                    'universe'

                    ]

        for d in data:

            if d in n:

                return False

        if actor.IsZone() or actor.IsBase() or actor.IsDeformer():

            return False

        if actor.IsLight() or actor.IsCamera():

            return False

        if actor.IsProp() or ( actor.IsBodyPart() and bodypart == True ):

            return True

    return False

for actor in scene.Actors():

    if valid().IsValid( actor ):

        # find first valid actor and select it 

        scene.SelectActor( scene.Actor( actor.Name() ) )

        break

Locked Out