How to check if a parm is a menu?

   862   0   1
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
parm.parmTemplate().type()
would return “menu” only if the parameter is an actual `Ordered Menu`.

But it turns out that you can build a menu from integers and string parameters as well, if you check the toggle “use menu”.
The thing to be aware of is that if you ask for their .type() they would be seen as `string` or `int`.
So how to check if a parameter has a menu?

I'm using a try/except solution:
try:
    parm.menuItems()
    print "this is a menu"
    
except:
    print "this is not a menu"

My questions:
1) This seems to work but maybe is there a better method to do it?
2) Is there any practical difference between and ordered menu and a integer menu? They seem to be the same.

I attached the hip file with the examples.


thanks for any help,
cheers
Edited by Andr - June 17, 2019 14:19:37

Attachments:
Q_menu_type.hiplc (49.5 KB)

  • Quick Links