Sometimes you need to know the length of a curve for some setups; for a while I sometimes used an addon called jsCurveLength.
However, the way it’s designed relies on the existance of the addon to evaluate. Without it, your rig is broken. I’ve made a version which is self-contained, so when you export your rig you don’t need to tell people to install any addon.
Select your curve(s) and run this code from either a button or the Script Editor. Here’s the JavaScript:
// Self-Contained CurveLength Op -- http://darkvertex.com/
function CurveLengthOp_Update( In_UpdateContext, Out, Incrvlist ) {
Out.Value = Incrvlist.Value.Geometry.Curves(0).Length;
return true;
}
function ApplyCurveLengthProp() {
oEnum = new Enumerator( Application.Selection ) ;
for (;!oEnum.atEnd();oEnum.moveNext() )
{
var sel = oEnum.item();
if (sel.Type == "crvlist") {
var oProp = sel.AddProperty( "Custom_parameter_list", false, "CurveLength" );
var p = oProp.AddParameter2("CurveLength",siDouble,0,-8000,8000,-8000,8000,siClassifUnknown,siPersistable | siAnimatable, "Length");
var crvList = sel.ActivePrimitive;
var newOp = AddScriptedOp( p, CurveLengthOp_Update.toString(), crvList, "CurveLengthOp", "JScript" );
newOp.Debug = 0;
newOp.AlwaysEvaluate = true;
newOp.Connect();
LogMessage("Added CurveLengthOp to: "+sel.FullName, siVerbose);
}
}
}
ApplyCurveLengthProp();
One reply on “Softimage: A Self-Contained CurveLength Operator”
Thank you very much for making this available to the public. Honestly, it’s beyond me why such a simple but important property isn’t available by default w/o any scripting requirements.
Very good work, works perfectly here.