PDA

View Full Version : Curve length as a parameter


floyd1510
09-17-2007, 09:14 AM
Hi. I wanted to know whether I could get the length of a curve in a parameter, say reflected in the x position of an object. When I run the function GetCurveLength() it gives me an error in the expression editor. I want to use it stretch my spine for a rig.

Also it would be great if somebody could recommend me to a good stretchy spine tutorial. I have done the spine tut in the Art of rigging book for Maya, but could not try the same here since I could not get curve length as a parameter.

Thanks and regards,

Vikram.

5quid
09-17-2007, 12:49 PM
I use a little scop to expose the curveinfo to a custom param. probably not the best way but for simple stuff it does the trick.

// JS_CurveInfoNodePlugin
function XSILoadPlugin( in_reg )
{
in_reg.Author = "Jon Swindells";
in_reg.Name = "JS_CurveInfoNodePlugin";
in_reg.Email = "squid@3d-palace.com";
in_reg.URL = "";
in_reg.Major = 1;
in_reg.Minor = 0;

in_reg.RegisterOperator("JS_CurveInfoNode");
in_reg.RegisterCommand("ApplyJS_CurveInfoNode","ApplyJS_CurveInfoNode");
//RegistrationInsertionPoint - do not remove this line

return true;
}

function XSIUnloadPlugin( in_reg )
{
var strPluginName;
strPluginName = in_reg.Name;
Application.LogMessage(strPluginName + " has been unloaded.",siVerbose);
return true;
}

function ApplyJS_CurveInfoNode_Init( in_ctxt )
{
var oCmd;
oCmd = in_ctxt.Source;
oCmd.Description = "Create an instance of JS_CurveInfoNode operator";
oCmd.SetFlag(siNoLogging,false);

var oArgs;
oArgs = oCmd.Arguments;
oArgs.AddWithHandler("Arg0","Collection");
return true;
}

function ApplyJS_CurveInfoNode_Execute(oArgs )
{
var rtnColl = new ActiveXObject("XSI.Collection") ;
for(var i = 0; i < oArgs.count; i++)
{
curr = oArgs(i);
if("crvlist" == curr.Type)
{
//cpset
var cpset = curr.AddCustomProperty("CurveLengthInfo" , false) ;
var param = cpset.AddParameter3( "Crv0Length", siDouble, 0, 0, 1000, true, false )

var newOp = XSIFactory.CreateObject("JS_CurveInfoNode");
newOp.AddOutputPort(param);
newOp.AddInputPort(curr + ".crvlist");
newOp.Connect();
rtnColl.Add(newOp);
}
}
return rtnColl;
}

function JS_CurveInfoNode_Define( in_ctxt )
{
var oCustomOperator;
oCustomOperator = in_ctxt.Source;
oCustomOperator.AlwaysEvaluate = true;
oCustomOperator.Debug = 0;
return true;
}

function JS_CurveInfoNode_Update( in_ctxt )
{
var crvList = in_ctxt.GetInputValue(0);
crvLen = crvList.Geometry.Curves(0).Length;
outPort = in_ctxt.OutputPort;
outPort.Value = crvLen;
return true;
}

save the code as a .js file and plop it in your $workgroup\Application\Plugins. refresh the plugin manager then run the command ApplyJS_CurveInfoNode(); with some curve(s) selected.

ignore the "JS_CurveInfoNode" field, the crv0Length parameter is where you hook into.

:)

CGTalk Moderation
09-17-2007, 12:49 PM
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.