def generic_syntax(cls): """ Creates a generic syntax object. Automatically added to any class using PluginMeta as a metaclass. If the class defines it's own syntax() class method, that will be used instead. """ m = MSyntax() m.setObjectType(MSyntax.kSelectionList) m.useSelectionAsDefault(True) return m
def arguments(cls, arglist, selection=True): """ Rturn the contents of arglist as a list of strings. If <selection> is True, the arglist will be populated with Maya selection """ syntax = MSyntax() syntax.setObjectType(MSyntax.kStringObjects) syntax.useSelectionAsDefault(selection) adb = MArgDatabase(syntax, arglist) return adb.getObjectStrings()
def objects(cls, arglist, selection=True): """ Returns the contents of arglist as an MSelectionList. If <selection> is True, uses the maya selection as the default. Note this does no error handling, if the argList has a bad object name a RuntimeError will be raised """ syntax = MSyntax() syntax.setObjectType(MSyntax.kSelectionList) syntax.useSelectionAsDefault(selection) try: adb = MArgDatabase(syntax, arglist) return adb.getObjectList() except RuntimeError as e: raise RuntimeError("could not parse argument list", cls.arguments(arglist))