- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
After the update to API 2.0, the MFnPlugin.registerTransform method has been removed. The only example of creating a custom transform node using Python still uses API 1.0 in the devkit examples (and the C++ API still uses that method as well, so I can't try to follow their examples either).
By guessing, I took the original code and stripped it down to the bare minimum just to try using MFnPlugin.registerNode with kTransformNode. This did not work and only yields the very not informative error:
RuntimeError: (kInvalidParameter): Invalid parameter
I really only want to create a transform node so it's visible in the Outliner as a DAG node without any shape node. It's not meant to do any transforming, just storing some data in attributes. If there is a better way, then please tell me 🙂 This is the code I have been using so far for testing, based on the original rockingTransform.py example:
import maya.api.OpenMaya as om
import sys
kRockingTransformPluginName = "spRockingTransform"
kRockingTransformNodeName = "spRockingTransformNode"
kRockingTransformNodeID = om.MTypeId(0x87014)
kRockingTransformMatrixID = om.MTypeId(0x87015)
class RockingTransformMatrix(om.MTransformationMatrix):
def __init__(self):
om.MTransformationMatrix.__init__(self)
class RockingTransformNode(om.MPxNode):
def __init__(self, transform=None):
if transform is None:
om.MPxNode.__init__(self)
else:
om.MPxNode.__init__(self, transform)
# create/initialize node and matrix
def matrixCreator():
return RockingTransformMatrix()
def nodeCreator():
return RockingTransformNode()
def nodeInitializer():
pass
def maya_useNewAPI():
pass
# initialize the script plug-in
def initializePlugin(mobject):
mplugin = om.MFnPlugin(mobject)
try:
mplugin.registerNode(kRockingTransformPluginName, kRockingTransformNodeID,
nodeCreator, nodeInitializer, om.MPxNode.kTransformNode) # <-- this will fail :(
except:
sys.stderr.write( "Failed to register transform: %s\n" % kRockingTransformPluginName )
raise
# uninitialize the script plug-in
def uninitializePlugin(mobject):
mplugin = om.MFnPlugin(mobject)
try:
mplugin.deregisterNode( kRockingTransformNodeID )
except:
sys.stderr.write( "Failed to unregister node: %s\n" % kRockingTransformPluginName )
raiseThanks in advance
Solved! Go to Solution.