This script will segment an entire curve from knot to knot. I needed something like this tool for my current project. I found this most useful for linear curves, but I added the code to segment a CV curve, as well.
Archive for the ‘Jscript’ Category
Segment Curve
Monday, May 31st, 2010if(oSel.Type != “crvlist”)
function fTrace(m){
function fSegmentCurve(oSel){
//FOR CUBIC CURVES – DEGREE 3
for(i=0; i < oNumKnots-1; i++)
//FOR LINEAR CURVES – DEGREE 1
for(i=0; i < oNumKnots-1; i++)
Two Rigging Tools
Sunday, May 30th, 2010I 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
/*
SELECT THE OBJECTS YOU WANT PARENTED TO A NULL, THEN RUN.
MATCHES THE NULL TO THE FIRST CHILD'S POSITION AND ROTATION.
*//*--------------------
User Input
--------------------*/ 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);
}
Script #2
Create Null as Parent at First Point on Curve
/*--------------------
SELECT CURVE(S) AND RUN
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.Kinematics.Local.PosY.Value = oPntY[0];
oNull.Kinematics.Local.PosZ.Value = oPntZ[0];
}
}
oNull.AddChild(inPath);
}
Illustrator File to 3D – Extract All Subcurves
Saturday, May 29th, 2010I’m working on a logo for a local singing group (which I’ll talk about more in the future), and I was frustrated with extracting one curve at a time from the .EPS import from Adobe Illustrator. So, I made a small tool to extract all the subcurves from a curve. Again, this is really handy if you’re importing designs from AI for use in Softimage.
To use this, copy and paste the code below into the Script Editor, select your curve, and run.
var oSel = Application.Selection(0);
var oSelName = oSel.FullName;
var oAP = oSel.ActivePrimitive.Geometry;
var oCrvCount = oAP.Curves.Count;
for(i=0; i < oCrvCount; i++)
{
ExtractFromComponents("ExtractSubCrvOp",
oSelName +".subcrv["+ i +"]", "crv_0"+i);
}


