When using the maya python API to create a new node type, I need to run a "maya.cmds.getAttr" on an attribute immediately after the node is created.
What is the proper way to get a dagPath to the node you just created in the postConstructor method?
When using the maya python API to create a new node type, I need to run a "maya.cmds.getAttr" on an attribute immediately after the node is created.
What is the proper way to get a dagPath to the node you just created in the postConstructor method?
When you are in the postConstrutor() method, you can use the 'thisMObject()' reference to access the node instance. From there, you can create the MDagPath and pass it to your getAttr commmand. But you do not need to do this, because you can use the API instead to access the attribute. For example:
thisNode = self.thisMObject()
plug = om.MPlug( thisNode, footPrint.size )
sizeVal = plug.asMDistance()
thisMObject() -> MObject
Returns the MObject associated with this user defined node. This makes it possible to use MFnDependencyNode or to construct plugs to this node's attributes.