Code: Select all
//FIRST DRAW A CURVE!!!
var crv = dictionary.getobject("crvlist");
FreezeObj(crv, null, null);
SelectObj(crv);
SetSelFilter("Isopoint");
//pick a point on the curve
var rtn = PickElement("isopoint");
var button = rtn.Value("ButtonPressed");
var iso = rtn.Value("PickedElement");
//get the percentage of the isopoint on the curve (0-1)
if (button!=0)
{
var e = iso.SubElements2.toArray();
var normU = e[1];
var U = crv.ActivePrimitive.Geometry.Curves(0).GetUFromNormalizedU(normU);
var P = crv.ActivePrimitive.Geometry.Curves(0).getPercentageFromU(U);
}
//display percentage
LogMessage("ISOPOINT: "+iso);
LogMessage("normU: "+normU);
LogMessage("U: "+U);
LogMessage("P: "+P);
//put null on curve using normU got from isopoint selection
var nul = Application.ActiveProject.ActiveScene.Root.addnull();
ApplyCns("Curve", nul, crv, null);
SetValue(nul+".kine.crvcns.posu", normU, null);
In my attempts to debug this I found the following post which would seem to suggest that all is not what it seems with these functions: https://groups.google.com/forum/#!topic ... -yazJigXyE but try as I might I can't get the solution suggested here (divide by length of curve) to work.
I have also tried this code:
Code: Select all
set oRoot = Application.ActiveProject.ActiveScene.Root
set oArc = oRoot.AddGeometry( "Arc", "NurbsCurve" )
UValue = oArc.ActivePrimitive.Geometry.Curves(0).GetUFromNormalizedU( 0.7 )
LogMessage "The equivalent to the normalized U: 0.7 is U :" & UValue
normUValue = oArc.ActivePrimitive.Geometry.Curves(0).GetNormalizedUFromU( UValue )
LogMessage "Normalized back it is:" & normUValue
-