Form and Space

creating CG 3D since 2001

  • Connect @
  • Linked in
  • Vimeo
  • Twitter

Two Rigging Tools

Matthew | May 30, 2010

1 Comment

I wish I made these tools a long time ago.     Script #1 is “Create Null as Parent”.  I especially like this one.  You can make fast hierarchies with this.

Script #1

/******************************
Create Null Parent
version 0.1

Format: Jscript
Author:  Matthew L. Stoehr
Source:  formandspace.com

SELECT THE OBJECTS YOU WANT PARENTED TO A NULL, THEN RUN.
MATCHES THE NULL TO THE FIRST CHILD'S POSITION AND ROTATION.


**************************************************************/

/*--------------------

User Input

--------------------*/


//start of timer
var oStartTime = new Date();

//For dynamic creation of primitives and curves
var oRoot = Application.ActiveProject.ActiveScene.Root;
//Selection Collection
var oSel = Application.Selection;


/*--------------------

FUNCTIONS

--------------------*/ 


fRun(oSel);

//end of timer
var oEndTime = new Date();
logMessage("Total time: " + (oEndTime - oStartTime)/1000);

function trace(oMessage){
	Application.LogMessage(oMessage);
}

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);
}

Script #2

/******************************

Create Null Parent for Curve
version 0.1

Format: Jscript
Author:  Matthew L. Stoehr
Source:  formandspace.com

Objective: Create a null as the parent at the first CVs location.

Directions: Select Curve(s) and Run

******************************************************/

/*--------------------
User Input
--------------------*/

//start of timer
var oStartTime = new Date();

//For dynamic creation of primitives and curves
var oRoot = Application.ActiveProject.ActiveScene.Root;

//Selection Collection
var oSel = Application.Selection;

//collect curves
var oCurveList = XSIFactory.CreateActiveXObject("XSI.Collection");


/*--------------------
FUNCTIONS
--------------------*/ 


fCollectCurves(oSel);

//end of timer
var oEndTime = new Date();
logMessage("Total time: " + (oEndTime - oStartTime)/1000);

function trace(oMessage){
	Application.LogMessage(oMessage);
} 


function fCollectCurves(oSel){
//Collect the curves	
	for(var en = new Enumerator (oSel); !en.atEnd(); en.moveNext())
	{
		oEn = en.item()
		oCurveList.Add(oEn);
	}
	
	for(k=0; k < oCurveList.Count; k++)
	{
			fTranslateNull(oCurveList(k));
	}
}

/*-------------------------------------------------
Translate the null to the fisrt point of the curve,
then parent the crv to the null.
--------------------------------------------------*/
function fTranslateNull(inPath)
{
	var oPntX = new Array();
	var oPntY = new Array();
	var oPntZ = new Array();	
	var oNull = oRoot.AddPrimitive("null");
	
	oVB = new VBArray(inPath.ActivePrimitive.Geometry.Points.PositionArray);
	oPntArray = oVB.toArray();
	
	for(i=0; i < oPntArray.length; i += 3)
	{
		oPntX[i] = oPntArray[i];
		oPntY[i] = oPntArray[i+1];
		oPntZ[i] = oPntArray[i+2];
	
		if(i == 0){
			trace("X "+oPntX[0]+", Y "+ oPntY[0]+", Z "+ oPntZ[0])
			//Translate(oNull, oPntX[0], oPntY[0], oPntZ[0])
			oNull.Kinematics.Local.PosX.Value = oPntX[0];
			oNull.Kinematics.Local.PosY.Value = oPntY[0];
			oNull.Kinematics.Local.PosZ.Value = oPntZ[0];
		}
	}	

	oNull.AddChild(inPath);

}

One response to “Two Rigging Tools”

Leave a Reply

Twitter

Subscribers

    396