Hi everyone,
I try to parent an instanciate shape to new transform with API.
With command is cmds.parent(my_shape, ma_new_parent, relative=True, shape=True)
All parenting function I've found need MObject in argument.
But with MObject it's my original shape was parented.
It's possible to have N MDagPath for one MObject (First is path of original shape, other is instanciate object). But I don't found solution for reparent instanciate shape....
If any have solution...
Here is my code:
# Duplicate shape
mfn_shape = OpenMaya.MFnDagNode(mo_node)
mo_duplicate = mfn_shape.duplicate(True, False)
# Retrieve shape.
# When duplicate shape, new parent is created and is returned by duplicate function
mfn_duplicate = OpenMaya.MFnDagNode(mo_duplicate)
dp_duplicate = OpenMaya.MDagPath()
mfn_duplicate.getPath(dp_duplicate)
dp_duplicate.extendToShape()
# print dp_duplicate.fullPathName() # Here long path is valid
# Reparent
# dp_duplicate.node() give original shape not new shape instance
mfn_parent = OpenMaya.MFnDagNode(mo_parent)
mfn_parent.addChild(dp_duplicate.node())