78 from builtins
import range
79 import maya.OpenMaya
as OpenMaya
80 import maya.OpenMayaMPx
as OpenMayaMPx
83 kPluginCmdName=
"spMotionTrace"
86 kStartLongFlag =
"-startFrame"
88 kEndLongFlag =
"-endFrame"
90 kByLongFlag =
"-byFrame"
93 class motionTrace(OpenMayaMPx.MPxCommand):
95 OpenMayaMPx.MPxCommand.__init__(self)
102 def doIt(self, args):
104 This method is called from script when this command is called.
105 It should set up any class data necessary for redo/undo,
106 parse any given arguments, and then call redoIt.
110 if argData.isFlagSet(kStartFlag):
111 self.__start = argData.flagArgumentInt(kStartFlag, 0)
112 if argData.isFlagSet(kEndFlag):
113 self.__end = argData.flagArgumentInt(kEndFlag, 0)
114 if argData.isFlagSet(kByFlag):
115 self.__by = argData.flagArgumentInt(kByFlag, 0)
122 This method performs the action of the command.
123 This method iterates over all selected items and
124 prints out connected plug and dependency node type
137 while not iter.isDone():
139 iter.getDependNode(dependNode)
140 picked.append(dependNode)
147 while (time <= self.__end):
152 for i
in range(picked.length()):
154 dependNode = picked[i]
160 txAttr = fnDependNode.attribute(
"translateX")
162 tx = txPlug.asDouble()
164 tyAttr = fnDependNode.attribute(
"translateY")
166 ty = tyPlug.asDouble()
168 tzAttr = fnDependNode.attribute(
"translateZ")
170 tz = tzPlug.asDouble()
172 print(
"adding", tx, ty, tz,
"\n")
178 for i
in range(picked.length()):
179 self.__jMakeCurve(pointArrays[i])
182 def __jMakeCurve(self, cvs):
184 Make a degree 1 curve from the given CVs.
186 Note that in Python, a double underscore in front of a member name
187 make the method "private" to the class through name-mangling
192 for i
in range(cvs.length()):
198 curveFn.create(cvs, knots, deg, OpenMaya.MFnNurbsCurve.kOpen,
False,
False, nullObj)
203 return OpenMayaMPx.asMPxPtr(motionTrace())
209 syntax.addFlag(kStartFlag, kStartLongFlag, OpenMaya.MSyntax.kLong)
210 syntax.addFlag(kEndFlag, kEndLongFlag, OpenMaya.MSyntax.kLong)
211 syntax.addFlag(kByFlag, kByLongFlag, OpenMaya.MSyntax.kLong)
216 def initializePlugin(mobject):
217 mplugin = OpenMayaMPx.MFnPlugin(mobject,
"Autodesk",
"1.0",
"Any")
219 mplugin.registerCommand(kPluginCmdName, cmdCreator, syntaxCreator)
221 sys.stderr.write(
"Failed to register command: %s\n" % kPluginCmdName)
226 def uninitializePlugin(mobject):
227 mplugin = OpenMayaMPx.MFnPlugin(mobject)
229 mplugin.deregisterCommand(kPluginCmdName)
231 sys.stderr.write(
"Failed to unregister command: %s\n" % kPluginCmdName)