Forum: Poser Python Scripting


Subject: P6: Identifying the selected figure and using that as a default in AskMenu()?

3dcheapskate opened this issue on Mar 22, 2012 · 3 posts


3dcheapskate posted Thu, 22 March 2012 at 12:55 AM

I'm using Poser 6 on a Win7 PC and writing a 'PropGoto' script to move/orient/parent the current actor to the right/left hand of the current figure. (I've already created smartprops, smart 'PropGoto' poses, and handgrip poses for my props - the ultimate goal of this script is to automatically apply the hand pose as well, but I need to overcome some very basic problems first!)

Okay, here's the relevant bit from my script (fig is already set to the current figure):

# Simple list (tuple) of options for figure selection drop-down
optlist = ("G2 James","James P6", ...etc... )

# Figure name matching list (tuple of tuples)
# (figure order is identical to optlist)
optlist2 = (("JamesG2"),("James","JamesCasual"), ...etc... )    

# Check the figure name against our figure name matching list
i = -1
iMatch = -1
for optsublist in optlist2:
    i = i+1
    for opt in optsublist:                  
        if fig.Name()[0:len(opt)] == opt:
            iMatch = i
            break
    if iMatch != -1:
        break

# Ask user to select/confirm figure
# (Hmmm... can't find a way to preselect the matched figure?)
if iMatch == -1:
    action = poser.DialogSimple.AskMenu("Select figure","Selected figure: "+fig.Name()+"nUnable to match figure.nPlease select figure from list:",optlist)
else
    action = poser.DialogSimple.AskMenu("Confirm figure","Selected figure: "+fig.Name()+"nFound match: "+optlist[iMatch],optlist)
    
# Set prop poition/orientation i.a.w. selected figure from drop-down
if action == optlist[0]: # G2 James RH values
    (yR,xR,zR,xT,yT,zT) = (-8.8,-21.1,-68.0,-0.29,0.57,0.04)
elif action == optlist[1]:
    ...etc...

Problem 1: Identifying the selected figure

The problem's not so much in finding the figure name, but in what it returns.

In Poser 6 fig.Name() seems to return the 'name' parameter from the 'figure' section of the CR2 - unfortunately many CR2s (all the DAZ generation 3 figures, Poser 5 Don/Judy, and MayaDoll) have name set to 'Figure'.

fig.InternalName() is no help as it's always 'Figure #'

The only other thing I can see that might help is fig.GeomFileName() ...

Problem 2: Setting a default option in the drop-down menu

The two lines in bold in the script extract show this. I already discovered that the AskMenu() function is incorrectly documented in the Poser 6 PoserPython Methods Manual, and it only takes three arguments. But the drop-down always seems to have an extra 'None' option which is always the default. Is there any way round this? Anything other than AskMenu I could use?


The 3Dcheapskate* occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.

*also available in ShareCG, DAZ, and HiveWire3D flavours (the DeviantArt and CGBytes flavour have been discontinued).