MStatus Molecule3Cmd::undoIt() { MDGModifier dgMod; MFnDagNode dagFn; MObject child; unsigned int i; for( i=0; i < objTransforms.length(); i++ ) { // N.B. It is important to delete the child shape before // the transform node, otherwise Maya will crash. dagFn.setObject( objTransforms[i] ); child = dagFn.child( 0 ); dgMod.deleteNode( child ); dgMod.deleteNode( objTransforms[i] ); } return dgMod.doIt(); }
void VertexPolyColourCommand::RemoveColoursNode(MDagPath& dagPath, MColorArray& colors) { MStatus status; MObject ourNode; if (FindNodeOnMesh(dagPath,ourNode)) { MDGModifier* modifier = new MDGModifier; // Delete the node status=modifier->deleteNode(ourNode); status=modifier->doIt(); if (m_isUndoable) m_undos.push_back(modifier); else delete modifier; } }
MStatus polyModifierCmd::cacheMeshData() { MStatus status = MS::kSuccess; MFnDependencyNode depNodeFn; MFnDagNode dagNodeFn; MObject meshNode = fDagPath.node(); MObject dupMeshNode; MPlug dupMeshNodeOutMeshPlug; // Duplicate the mesh // dagNodeFn.setObject( meshNode ); dupMeshNode = dagNodeFn.duplicate(); MDagPath dupMeshDagPath; MDagPath::getAPathTo( dupMeshNode, dupMeshDagPath ); dupMeshDagPath.extendToShape(); depNodeFn.setObject( dupMeshDagPath.node() ); dupMeshNodeOutMeshPlug = depNodeFn.findPlug( "outMesh", &status ); MCheckStatus( status, "Could not retrieve outMesh" ); // Retrieve the meshData // status = dupMeshNodeOutMeshPlug.getValue( fMeshData ); MCheckStatus( status, "Could not retrieve meshData" ); // Delete the duplicated node // MDGModifier deleter; deleter.deleteNode(dupMeshNode); deleter.doIt(); //MGlobal::deleteNode( dupMeshNode ); return status; }