Python (Maya) pass flags as variables -


i'm trying run command, specific flags dependant on options i've selected in ui. specifically, maya, , trying create new attribute on selected object. problem is, depending on type of attribute want create, i'll have different flags, , i'm not sure how pass these flags command itself. here relevant code i'm having issues with

typenum= #gets value radio button group if typenum==1:     type='at="enum", en="off:on"' elif typenum==2:     type='at="float", min=0, max=1'  cmds.addattr(selectedobject, ln="attrnametextfield", type, k=true") 

i hope type plug in @ flag (attrbute type) ether en flag (enum names), or min , max flags. unfortunately, it's not recognizing variable flags,and returns "syntaxerror: non-keyword arg after keyword arg" error. there has got way build command , run it, it's been long while since i've coded ui items, , i'm drawing blank.

thanks time.

ps: haven't gotten far, suspect min/max values won't recognized integers. if have suggestion resolve that, next potential hurdle.

the standard way pass flags maya command use python's built-in **args syntax:

mesh_options = {'type':'mesh', 'long':true }  meshes = cmds.ls(**mesh_options) 

is equivalent

cmds.ls(long=true, type='mesh')  

in case want like

opts = {"ln":"attrnametextfield","k":true} if typenum == 1:    opts["at"] = "enum"    opts["en"] = "off:on" else:    opts["at"] = "float"    opts["min"] = 0    opts["max"] = 1 cmds.addattr(selectedobject, **opts) 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -