Reputation: 851
I'm in the process of creating a custom import plugin for maya. I already wrote some import code and created a custom MPxSurfaceShape
class (I'm mainly interested in drawing the surface from within the viewport).
The shape gets crated by a MPxCommand
which reads a file from the disk. Now I would like to add this object to my maya scene from within the plugin. But unfortunately I can't find a function that takes a MPxNode
/MPxSurfaceShape
and adds it to Maya so that it can be displayed.
In all examples I've seen the node is instantiated from within mel. But I want to link this instance a file. Which prevents me from just creating the node and then editing it.
A similar solution might be found in either the apiMeshShape
example in the maya plugin folder or here: https://github.com/ADN-DevTech/Maya-Locator/ (also supports the loading of external data).
Upvotes: 2
Views: 1255
Reputation: 277
Here's something I hope will help.
MDagModifier dagMod;
MObject newNode = dagMod.MDGModifier::createNode("Node Name")
dagMod.doIt()
or
MDagModifier dagMod;
MObject newNode = dagMod.MDGModifier::createNode(Node::id)
dagMod.doIt()
From there you have an MObject you can make into other things.
//Dag Node example.
MFnDagNode new_MDagNode(newNode);
//Dependency Node.
MFnDependencyNode new_DependNode(newNode);
The MPxNode also has thisMObject() which will give you the current MObject in the MPxNode. http://download.autodesk.com/us/maya/2010help/API/class_m_px_node.html#9608c582da0945e792c3f9893661404d
Again I'm not sure I fully understand the question, but I hope this helps.
Upvotes: 3