## MakeLeg

### Introduced

v4.0

### Description

Creates a two bone leg with an up vector control object. The leg bones are created from a collection of guide objects, containing a guide for the hip socket, the knee joint, and the ankle respectively.
MakeLeg can optionally add roll divisions to the thigh. Roll divisions are used to distribute the roll difference between adjacent bones over the length of a bone. When used as deformers on an envelope they evenly distribute twist along the length of a bone giving a more natural skin deformation. Roll divisions can also be added separately using the MakeBicepRoll command.
Optionally a shadow rig can be attached to the leg. Shadow objects are created for each chain element in the leg, and shadow bones are pose-constrained to the acutal leg bones. Shadow rigs can be used to plot animation off of a rig.

### Scripting Syntax

    oLeg = MakeLeg( Model, Parent, [Prefix], GuideObjectCollection, [UpVectorBehindLeg], [NbThighDivisions], [ShadowType], [ShadowParent] );

### Return Value

Returns a Leg JScript object.

### Parameters

Parameter | Type | Description
--- | --- | ---
Model | String | The model the leg will belong to.
Parent | String | The parent of the new leg.
Prefix | String | The naming prefix for the newly created leg objects.
GuideObjectCollection | String | A list of 3 objects to search for when making the leg: 1) Top of leg; 2)Knee joint; 3)Ankle.
UpVectorBehindLeg | Boolean | Determines whether the upvector is places behind the leg (-z globally) or in front (+z globally). Default Value: False
NbThighDivisions | Integer | The number of roll divisions. If the value is zero no roll is created. Default Value: 3
ShadowType | Integer | The type of shadow rig to attach to the leg. Shadow rigs can be used to transfer or remap animation. Default Value: 0
Possible Values: | Description:
0 | No shadow
1 | SI|3D Skeleton shadow rig
2 | XSI Skeleton shadow rig
3 | Null shadow rig
4 | Box shadow rig
ShadowParent | String | Parent of the shadow rig hiearchy. If empty, no shadow rig is generated.

### Examples

#### JScript Example

    /*

    	This script creates two legs, left and right

    	Left  leg has thigh roll divisions

    	Right leg has a box shadow hierarchy

    */

    var guidecoll = new ActiveXObject("XSI.Collection");

    guidecoll.Add( GetPrim("Null", "Guide_HipJoint") );

    guidecoll.Add( GetPrim("Null", "Guide_KneeJoint") );

    guidecoll.Add( GetPrim("Null", "Guide_AnkleJoint") );

    var lXfm = guidecoll(0).Kinematics.Global.Transform

    var lNull = GetPrim("Null", "Legs");

    /*

    	Right Leg

    */

    lXfm.SetTranslationFromValues(2,4,0);

    guidecoll(0).Kinematics.Global.Transform = lXfm;

    lXfm.SetTranslationFromValues(2,0,-1);

    guidecoll(1).Kinematics.Global.Transform = lXfm;

    lXfm.SetTranslationFromValues(2,-4,0);

    guidecoll(2).Kinematics.Global.Transform = lXfm;

    var RLeg= MakeLeg(lNull, GetPrim("Null", "RLegParent"),"R", guidecoll, true, 0, 4, GetPrim("Null", "RShadowParent") );

    Logmessage("Right Leg");

    DumpLeg(RLeg);

    /*

    	Left Leg

    */

    lXfm.SetTranslationFromValues(-2,4,0);

    guidecoll(0).Kinematics.Global.Transform = lXfm;

    lXfm.SetTranslationFromValues(-2,0,-1);

    guidecoll(1).Kinematics.Global.Transform = lXfm;

    lXfm.SetTranslationFromValues(-2,-4,0);

    guidecoll(2).Kinematics.Global.Transform = lXfm;

    var LLeg = MakeLeg(lNull , GetPrim("Null", "LLegParent"),"L", guidecoll);

    Logmessage("Left Leg");

    DumpLeg(LLeg);

    function DumpLeg(inLeg)

    {

    	logmessage ("Data in the returned leg:");

    	logmessage ("------------------------");

    	logmessage ("Root        : " + inLeg.Root);

    	logmessage ("Effector    : " + inLeg.Eff);

    	logmessage ("UpVector    : " + inLeg.upV);

    	logmessage ("Skeleton    : " + inLeg.Skel);

    	if(inLeg.ThighDivisions>0)

    	{logmessage ("Thigh Divs  : " + inLeg.ThighRoll.Divisions);}

    	logmessage ("Hidden      : " + inLeg.Hidden);

    	logmessage ("Envelope    : " + inLeg.Envelope);

    	logmessage ("ShadowsStart: " + inLeg.ShadowStart);

    	logmessage ("ShadowsEnds : " + inLeg.ShadowEnds);

    	logmessage ("Shadows     : " + inLeg.Shadows);

    }

    //results of running this command:

    //INFO : Right Leg

    //INFO : Data in the returned leg:

    //INFO : ------------------------

    //INFO : Root        : RRoot

    //INFO : Effector    : RlegEff

    //INFO : UpVector    : RlegUpV

    //INFO : Skeleton    : RRoot,RThigh,RShin,RlegEff

    //INFO : Hidden      : RRoot,RlegEff

    //INFO : Envelope    : RThigh,RShin

    //INFO : ShadowsStart: RThigh1

    //INFO : ShadowsEnds : RForeleg

    //INFO : Shadows     : RThigh1,RForeleg

    //

    //INFO : Left Leg

    //INFO : Data in the returned leg:

    //INFO : ------------------------

    //INFO : Root        : LRoot

    //INFO : Effector    : LlegEff

    //INFO : UpVector    : LlegUpV

    //INFO : Skeleton    : LRoot,LThigh,LShin,LlegEff

    //INFO : Thigh Divs  : LBicepRoll1,LBicepRoll2,LBicepRoll3,LBicepRoll_4

    //INFO : Hidden      : LRoot,LlegEff

    //INFO : Envelope    : LShin,LBicepRoll1,LBicepRoll2,LBicepRoll3,LBicepRoll_4

    //INFO : ShadowsStart: undefined

    //INFO : ShadowsEnds : undefined

    //INFO : Shadows     : undefined

### See Also

MakeDogLeg MakeArm MakeThighSlide MakeFoot