Thu, Jan 2, 5:53 PM 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 Dec 02 3:16 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: P6: Identifying the selected figure and using that as a default in AskMenu()?


3dcheapskate ( ) posted Thu, 22 March 2012 at 12:55 AM · edited Sun, 22 December 2024 at 2:14 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).



markschum ( ) posted Thu, 22 March 2012 at 11:05 AM

You have found the issues in Poser of identifying a figure. For your own use you could edit the cr2 and put in a meaningful name.  

The geometry file name will tell you some things but V4, A4, etc will show the same geometry file since they are essentially morphs of v4.  You can look for specific morphs or materials but thats a bit hit-or-miss if you have characters.  

You can add code to treat the None entry as an error and ask again for a valid selection but thats all.  You can use tkinter and create a list for selection but thats a lot harder in my opinion. 


3dcheapskate ( ) posted Fri, 23 March 2012 at 12:03 PM · edited Fri, 23 March 2012 at 12:06 PM

Thanks. The 'PropGoto' script I'm doing is for the Renderosity Freestuff, so a CR2 edit isn't an option.

But as luck would have it I actually want to treat V4, A4, etc as one item (the hand position of the zeroed V4 and the V4 hand pose I've created work just as well for A4 and She-Freak 4. Same goes for M4, H4, etc). So using the geometry file name seems a good option for my particular purposes.

Having just started writing Python and DAZ Scripts, I think trying to understand tkinter (or wxPython) as well would probably be a step too far at the present time.

So a quick rethink with the AskMenu() - adding a YesNo() if a match is found prevents the need for an askmenu() provided the match is accurate. And if the match is bad (or no match is found) then checking to ensure the user actually makes a valid selection from the AskMenu() should do it.

# Ask user to select/confirm figure
if iMatch == -1:

   * # If no match was found then user must select a figure from the dropdown or cancel*
    action = ""
    while action == "":
        action = poser.DialogSimple.AskMenu("Select Figure","Figure: "+fig.Name()+"nUnable to match figure.nPlease select match from list:",optlist)

else:

    # If a match was found simply display the match and ask user to confirm it
    yn = poser.DialogSimple.YesNo("Figure: "+fig.Name()+"nMatch: "+optlist[iMatch]+"nYes to confirm, No to select match manually")

    # If user confirms, then use the match
    if yn:
        action = optlist[iMatch]

    # if user refuses the match then they  must select a figure from the dropdown or cancel
    else:
        action = ""
        while action == "":
            action = poser.DialogSimple.AskMenu("Select Figure","Figure: "+fig.Name()+"nPlease select match from list:",optlist)

(Note: selecting the default "None" in the AskMenu() and clicking OK returns an empty string, whereas clicking Cancel returns the NoneType)

I think that ought to do it - except that AskMenu() only seems to allow a 16 character message!


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).



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.