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 3:20 AM Forum Coordinator

proplist = [ac for ac in poser.Scene().Actors() if actor.IsProp() and hasattr(actor, "Geometry") and actor.Geometry() is not None and actor.Geometry.NumVertices() > 0]
if len(proplist) == 0:
    print("No usable props in this scene.")
elif len(proplist) == 1:
    print("The one and only prop: ", proplist[0]
else:
    # make something to select one of the props.
    print("All the props:", proplist)

I Just tried this and this was the list of props returned from a new installation default scene :

FocusDistanceControl
GROUND
CenterOfMass
GoalCenterOfMass
rThumb0Con
rIndex0Con
rMid0Con
rPinky0Con
rRing0Con
lThumb0Con
lIndex0Con
lMid0Con
lRing0Con
lPinky0Con
UpperBrowCon
RightOuterBrowCon
LeftOuterBrowCon
MidBrowCon
RightInnerBrowCon
LeftInnerBrowCon
RightUpperEyeLidCon
LeftUpperEyeLidCon
RightLowerEyeLidCon
RightUpperCheekCon
LeftUpperCheekCon
RightLowerCheekCon
LeftLowerCheekCon
NoseCon
RightNostrilCon
LeftNostrilCon
UpperLipCon
RightUpperLipCon
RightLipCon
LeftUpperLipCon
LeftLipCon
RightEarCon
RightEarLobeCon
LeftEarLobeCon
LeftEarCon
LeftLowerEyeLidCon
RightBreastCon
LeftBreastCon
RightGluteCon
LeftGluteCon
LowerLipCon 1
RightLowerLipCon 1
LeftLowerLipCon 1
JawCon
MonsPubisCon
AmorHair
CenterOfMass
GoalCenterOfMass

which leads me to believe ( based on this script testing for valid geometries ) that FocusDistanceControl, CenterOfMass, and GoalCenterOfMass all have geometries; if that is the case, then this script fails to eliminate props that you would not want to have show up in your list.

Locked Out