Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Issue creating nodes in API [C++]

Issue creating nodes in API [C++]

Anonymous
Not applicable
442 Views
1 Reply
Message 1 of 2

Issue creating nodes in API [C++]

Anonymous
Not applicable

I'm learning and I compiled the ApiMesh example all went ok etc.

On that example a mel script is providen to test it

createNode apiMesh;
createNode apiMeshCreator;
connectAttr apiMeshCreator1.outputSurface apiMesh1.inputSurface ;

 

 

But I cannot replicate that on C++, I tried with the most logical idea:

//create mesh
MDagModifier dgMod;
MObject oApiMesh = dgMod.createNode(apiMesh::id, MObject::kNullObj, &status);
CHECK_MSTATUS_AND_RETURN_IT(status);
status = dgMod.doIt();

//create mesh creator
MDGModifier dgbMod;
MObject oApiMeshCreator = dgbMod.createNode(apiMeshCreator::id, &status);
CHECK_MSTATUS_AND_RETURN_IT(status);
status = dgbMod.doIt();

//connect them
apiMeshCreator* myMeshCreator = (apiMeshCreator*)&oApiMeshCreator;
apiMesh* myMesh = (apiMesh*)&oApiMesh;
dgMod.connect(oApiMeshCreator, myMeshCreator->outputSurface, oApiMesh, myMesh->inputSurface);
status = dgMod.doIt();

 

 

But nothing happens, notice that I used MDGModifier to create the apiMeshCreator (it inherits from MPxNode) since using MDagModifier the plugin crashes.

 

Any idea? Thank you in advance

0 Likes
443 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Hi

 

In the past this is what I have done to create Meshes in Maya:

 

First create a Transform object -- because all Meshes need a transform reference:

Then I created a Mesh via MFnMesh.

Then I updated the DGs.  and it worked for me.

 

MObject meshTransformObj = dgModifier.createNode("transform");

MFnDependencyNode dpNode(meshTransformObj);
dpNode.setName("meshTransform");

 

MFnMesh mesh;
mesh.create((int)uniquePositionsList.size(), (int)triangles, mPointArray, polygonCounts, polygonConnects, uArray, vArray, meshTransformObj);

mesh.setName("Mesh");

 

...

 

dagModifier.doIt();

dgModifier.doIt();