MStatus status; MFnDependencyNode nodeFn; MFnNumericAttribute numAttrFn; // Create a new node definition. const MTypeId nodeID(0x12345678); const MString nodeName("myNode"); MFnPluginData pluginDataFn; MObject defaultAttrData = pluginDataFn.create("myPluginDataType"); MFnTypedAttribute typedAttrFn; MObject inputAttr = typedAttrFn.create("input", "in", MFnData::kString); // Create a numeric attribute. MObject outputAttr = numAttrFn.create("output", "out", MFnNumericData::kDouble, 0.0); numAttrFn.setMin(0.0); numAttrFn.setMax(1.0); // Add the attributes to the node definition. MObject nodeDef = nodeFn.create(nodeID, nodeName, &status); nodeFn.addPlug(inputAttr); nodeFn.addAttribute(outputAttr); nodeFn.setObject(nodeDef); // Create an instance of the node. MObject node = nodeFn.create(defaultAttrData, &status);
MStatus status; MSelectionList selList; selList.add("myNode"); // Find the node in the scene. MObject node; selList.getDependNode(0, node); if (!node.isNull()) { MFnDependencyNode nodeFn(node, &status); if (status == MS::kSuccess) { // Do something with the node. } }This example finds a node in the scene with the name "myNode" and retrieves its MObject. The MObject is then used to create an instance of the MFnDependencyNode class, which can be used to manipulate the node. Package/Library: Autodesk Maya C++ API