Parent Constrain Multiple Objects

I know how to apply multiple parent constraints to a single child but there seems to be no way to parent constrain multiple children to a single parent. Anybody know how to go about this seemingly very simple and obvious function?

Hasnt anyone ever had to parent a hundred things to one thing and not want to hand constrain each one?

Constrain one object to another, open the script editor, you should see something like this:

QUOTE
//Select first sphere
select -r pSphere1 ;
//Select second sphere
select -tgl pSphere2 ;
//Now create a point constrain with an offset of 0/0/0 and a weight of 1
pointConstraint -offset 0 0 0 -weight 1;

cut it, paste it into a text editor, make duplicates of your process, replace the objects names (sphere2 to sphere3, sphere4...), end up with one big master script, paste it back into the script editor, use the "Execute" command and, presto, there you are.

Cheers

Chris

Hi
Try this. Copy, Paste and save as parentConstrainMulti.mel. source it and add to a shelf if required.

//1.) Select an object, then shift select any number of targets.
//2.) Execute parentConstrainMulti; to create constraints.

global proc parentConstrainMulti()
{
string $sel[] = ls -sl;

if ($sel[0] != "")
{
    for ($obj in $sel)
    {

        if ($obj != $sel[0])
        {
            parentConstraint -mo -weight 1 $sel[0] $obj;
        }

    }

}

}

Aaaah, now THAT is real scripting. thumbsup

Chris

Hi

Thanks for the "nice " comment.

The script came froma section in CG_ToolKit Art of Rigging Vol 2. and excellent set of 3 books which I use to help learn scripting and then built the "Davvey Vegicle Rigging Script Pack".

I have also built a set of these for each type of Constarint by editing it for Point Orient etc.

I

Hi

Absolutely.

Before buying and reading these book I had done very little with scripting. Don't know if you've seen the script pack I did for vehicles but all this was done after reading the first two volumes. I would recommend them to anybody wanting to improve their scripting skills.

The 3D-World Mag gave the first vol a 10 out of 10 rating and the second was 9 out of 10. Also one of the authours recently did a tutourial in one of the latest Mags as well. The last volume 3 is slightly different as not so much scripting as first two but still very good and the scripts shown are for two of Maya's more difficult areas Hair and Cloth.

The explanation and detail is excellent as each script is demonstrated, explained and then a detailed walk through to show how to build each script from start to finish.

Hi davvey , thank you for your sharing. But, there is some error message heppened
// Error: Line 3.23: Invalid use of Maya object “sl”.
I am new in Mel script , Could you give me some advices to slove this? Thank you~

It’s now 15 years later but you just need upticks around the ls -sl
Unfortunately Highend3d forums usually delete any upticks when you hit reply so you’ll have to put them in yourself. If you’re on a PC it’s the key in the top left of your keyboard to the left of the number 1

You’d think that in 15 Years this might have been made possible in Maya without any scripting but apparently not!

2 Likes