Forum: Poser Python Scripting


Subject: Simple return value bug in poser.DialogSimple.AskMenu()

3dcheapskate opened this issue on Sep 26, 2020 ยท 7 posts


3dcheapskate posted Sat, 26 September 2020 at 10:04 PM

According to the Poser 11 PoserPython manual AskMenu returns a StringType.

This is correct, EXCEPT if you click the 'Cancel' button on the dialogue, when it returns a NoneType.

To catch that I found I had to cast (if that's the correct Pythonspeak) the return value as a string, which appears to convert NoneType to "None".


        ...
        action = ""
        while action == "":
            # According to the Poser 11 PoserPython manual AskMenu() returns .
            # If you select an option from the list and hit 'OK' it returns that option as a string.
            # If you hit 'OK' with 'None' selected it returns "".
            # BUT if you hit 'Cancel' it actually returns , so I have to cast the return value as a string just in case (it will be "None" for )
            action = poser.DialogSimple.AskMenu("Multiple 'SmartPlusData.txt' files found","Select which to use:",foundfilelist)
        locatedfile = str(action)
        ...

I don't recall having this problem with PP2014, although it's possible I never tested clicking the Cancel button from an AskMenu

(N.B. this darn forum s**tware removed anything between (and including) less-than and greater-than symbols, so the types in my code extract disappeared, despite being within a triple backtick block )`


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