Home Technical Talk

Maya - Parent selected into target mesh's group (not parent under selected object)

polycounter lvl 4
Offline / Send Message
Pinned
tomofnz@gmail.com polycounter lvl 4
Parenting by target group...
I'm just wondering, is there a way to do this already?
Is there a mel to parent meshes to the last picked mesh's immediate parent (group) rather than parent as usual (mesh nests under mesh).
Using P to parent is nice, but it takes some added time to pick two objects, find the group of the target in the outliner, then parent the first mesh to that group instead.

Replies

  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    Yes you could do it through mel. It would be some combination of the listRelatives command and the parent command. Something like this:
    global proc parentStuff(){<br>&nbsp; &nbsp; string $selObjs[] = `ls -sl`;
    <br>&nbsp; &nbsp; string $targetObj[] = `ls -selection -tail 1`;<br>&nbsp; &nbsp; string $parentObj[] =  ` listRelatives -parent $targetObj[0]`;
    <br>&nbsp; &nbsp; for ($obj in $selObjs){<br>&nbsp; &nbsp; &nbsp; &nbsp; parent $obj $parentObj[0];<br>&nbsp; &nbsp; }
    }


  • tomofnz@gmail.com
    Options
    Offline / Send Message
    tomofnz@gmail.com polycounter lvl 4
    Python version
    import pymel.core as pm<br>selected_objects = pm.ls(sl=True)<br>parent_group = selected_objects[-1].getParent()<br>selected_objects.remove(selected_objects[-1])<br><span>pm.parent(selected_objects, parent_group)&nbsp;</span>

Sign In or Register to comment.