22 from builtins
import range
23 from builtins
import next
24 import maya.OpenMaya
as OpenMaya
25 import maya.OpenMayaMPx
as OpenMayaMPx
27 kPluginCmdName =
"py1MultiPlugInfo"
29 kIndexFlagLong =
"-index"
32 def advance(arrayHdl):
42 class multiPlugInfo(OpenMayaMPx.MPxCommand):
44 OpenMayaMPx.MPxCommand.__init__(self)
46 self.__isIndex =
False
50 This method is called from script when this command is called.
51 It should set up any class data necessary for redo/undo,
52 parse any given arguments, and then call redoIt.
56 if argData.isFlagSet(kIndexFlag):
61 argData.getObjects(slist)
62 if slist.length() == 0:
63 print(
"Must specify an array plug in the form <nodeName>.<multiPlugName>.")
67 slist.getPlug(0, plug)
69 print(
"Must specify an array plug in the form <nodeName>.<multiPlugName>.")
73 dh = plug.asMDataHandle()
78 print(
"Could not create the array data handle.")
79 plug.destructHandle(dh)
84 for i
in range(adh.elementCount()):
86 indx = adh.elementIndex()
92 self.appendToResult(indx)
96 if h.numericType() == OpenMaya.MFnNumericData.kBoolean:
97 self.appendToResult(h.asBool())
98 elif h.numericType() == OpenMaya.MFnNumericData.kShort:
99 self.appendToResult(h.asShort())
100 elif h.numericType() == OpenMaya.MFnNumericData.kInt:
101 self.appendToResult(h.asInt())
102 elif h.numericType() == OpenMaya.MFnNumericData.kFloat:
103 self.appendToResult(h.asFloat())
104 elif h.numericType() == OpenMaya.MFnNumericData.kDouble:
105 self.appendToResult(h.asDouble())
107 print(
"This sample command only supports boolean, integer, and floating point values.")
110 plug.destructHandle(dh)
114 return OpenMayaMPx.asMPxPtr(multiPlugInfo())
120 syntax.addFlag(kIndexFlag, kIndexFlagLong, OpenMaya.MSyntax.kNoArg)
121 syntax.setObjectType(OpenMaya.MSyntax.kSelectionList, 1, 1)
125 def initializePlugin(mobject):
126 mplugin = OpenMayaMPx.MFnPlugin(mobject,
"Autodesk",
"1.0",
"Any")
128 mplugin.registerCommand(kPluginCmdName, cmdCreator, syntaxCreator)
130 sys.stderr.write(
"Failed to register command: %s\n" % kPluginCmdName)
133 def uninitializePlugin(mobject):
134 mplugin = OpenMayaMPx.MFnPlugin(mobject)
136 mplugin.deregisterCommand(kPluginCmdName)
138 sys.stderr.write(
"Failed to unregister command: %s\n" % kPluginCmdName)