PDA

View Full Version : Create a Null as Parent


Stoehr
05-30-2010, 10:14 AM
This will create a null as the parent and match the parent translation and rotation to the first child selected. Handy when rigging. Using this more once creates a hierarchy very fast.

/*
SELECT THE OBJECTS YOU WANT PARENTED TO A NULL, THEN RUN.
MATCHES THE NULL TO THE FIRST CHILD'S POSITION AND ROTATION.
*/
var oRoot = Application.ActiveProject.ActiveScene.Root;
var oSel = Application.Selection;

/*--------------------
FUNCTIONS
--------------------*/
fRun(oSel);

function fRun(oSel){
var oNull = oRoot.AddPrimitive("Null", oSel(0).Name+"_null")

oNull.Kinematics.Local.PosX.Value = oSel(0).Kinematics.Local.PosX.Value;
oNull.Kinematics.Local.PosY.Value = oSel(0).Kinematics.Local.PosY.Value;
oNull.Kinematics.Local.PosZ.Value = oSel(0).Kinematics.Local.PosZ.Value;

oNull.Kinematics.Local.RotX.Value = oSel(0).Kinematics.Local.RotX.Value;
oNull.Kinematics.Local.RotY.Value = oSel(0).Kinematics.Local.RotY.Value;
oNull.Kinematics.Local.RotZ.Value = oSel(0).Kinematics.Local.RotZ.Value;

oNull.AddChild(oSel)
SelectObj(oNull);

}

CGTalk Moderation
05-30-2010, 10:14 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.