isopoint misreporting percentage position on curve (i think)

Discussions concerning programming of SOFTIMAGE©
Post Reply
janrogowski
Posts: 6
Joined: 04 Jul 2013, 16:56

isopoint misreporting percentage position on curve (i think)

Post by janrogowski » 04 Jul 2013, 18:24

Hi all

Odd one this, not sure if I'm missing something obvious. I'm trying to take a user selected isopoint on a curve, figure out it's percentage position on the curve and feed this into a path constraint to add a null at that point along the curve. Script below does exactly that, except the nulls it generates are accurately placed when the curve is linear and has 2 control points. Once the curve becomes more complicated then it appears the reported percentage from the isopoint selection gets wildly inaccurate.

Any ideas welcome!

Code: Select all

//FIRST DRAW A CURVE!!!
var crv = dictionary.getobject("crvlist");

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 p = e[1];
}

//display percentage
LogMessage("ISOPOINT: "+iso);
LogMessage("PERCENTAGE: "+p*100);

//put null on curve using percentage got from isopoint selection
var nul = Application.ActiveProject.ActiveScene.Root.addnull();
ApplyCns("Path", nul, crv, null);
SetValue(nul+".kine.pathcns.perc", p*100, null);
Moderator edit: added optional code tags - HB

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 15:31
Skype: csaezmargotta
Location: Sydney, Australia
Contact:

Re: isopoint misreporting percentage position on curve (i think)

Post by csaez » 05 Jul 2013, 00:27

Hi,
The picker is not returning a percentage value, but the U coordinate. Try applying a 'curve' constraint instead ;)

Cheers!

janrogowski
Posts: 6
Joined: 04 Jul 2013, 16:56

Re: isopoint misreporting percentage position on curve (i think)

Post by janrogowski » 05 Jul 2013, 10:10

I was missing something obvious! Thanks, much obliged!
Jan.

Post Reply

Who is online

Users browsing this forum: No registered users and 44 guests