Here is something interesting. If you try to parent an existing object (on user select for example) to a newly created transform node by running the code below all at once, everything works fine.
import maya.OpenMaya as api
DGMod = api.MDagModifier()
nO = DGMod.createNode('transform')
nFn = api.MFnDagNode(nO)
nFn.setName('TAO')
DGMod.doIt()
# ---------------------------------------------
selection = api.MSelectionList()
api.MGlobal.getActiveSelectionList(selection)
selectionObjList = api.MObjectArray()
for i in range(selection.length()):
mObj = api.MObject()
selection.getDependNode(i, mObj)
selectionObjList.append(mObj)
# ---------------------------------------------
for i in range(selectionObjList.length()):
DGMod.reparentNode(selectionObjList[i], nO)
DGMod.doIt()
Now replace node type to ‘lodGroup’ and run entire code again - it will actually crash Maya.
Now try to run it a code block at a time - works fine…
Edit: Confirmed on versions 2011 - 2014
Edit: Confirmed on both sets of api (maya.OpenMaya & maya.api.OpenMaya)
Any thoughts?
Cheers!