MSelectionList selList; MGlobal::getActiveSelectionList(selList); MObject node; selList.getDependNode(0, node); MDagPath dagPath; MDagPath::getAPathTo(node, dagPath); cout << dagPath.fullPathName() << endl;
MSelectionList selList; MGlobal::getActiveSelectionList(selList); MObject node; selList.getDependNode(0, node); MDagPath dagPath; MDagPath::getAPathTo(node, dagPath); MDagModifier mod; mod.createNode("transform", dagPath.pop()); mod.doIt();This code retrieves the active selection list, gets the first selected node, creates a new transform node at its parent's location, and moves the selected node to the new transform node. This code uses the Maya API package library.