PDA

View Full Version : Create Null as Parent at First Point of a Curve


Stoehr
05-30-2010, 09:30 AM
As the title says. This was handy for the logo I imported from AI. Works on multiple curves.

/*--------------------
User Input
--------------------*/
var oRoot = Application.ActiveProject.ActiveScene.Root;
var oSel = Application.Selection;

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

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

function fCollectCurves(oSel){

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

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){
oNull.Kinematics.Local.PosX.Value = oPntX[0];
oNull.Kinematics.Local.PosY.Value = oPntY[0];
oNull.Kinematics.Local.PosZ.Value = oPntZ[0];
}
}

oNull.AddChild(inPath);

}

CGTalk Moderation
05-30-2010, 09:30 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.