How to use GetSegmentLength()

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/11/2009 at 06:44, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   10 
Platform:   Windows  ;   Mac OSX  ; 
Language(s) :     C++  ;

---------
Hi,

I want to iterate over all segments of a spline and retrieve the length of each segment. It seems GetSegmentLength() would be the function to use, but I get stupid results. Maybe it's not documented correctly.

Here's the code:

  
// Iterate Segments, treat each segment like a separate spline (as in the old function)   
for (s = C_ZERO; s < SegmentCount; s++)   
{   
     // Get this segment's length   
     ThisSegmentLength = sp->GetSegmentLength(s, s+1);   
     GePrint("Segment " + LongToString(s) + ": " + RealToString(ThisSegmentLength) + " units.");   
}   

So what are those two parameter that I have to pass to GetSegmentLength()? In the documentation it sais:

Parameters
LONG a
Start segment.

LONG b
End segment.

But that doesn't seem to be correct. For example, my spline only has one segment, and a total length of some hundred units. But GetSegmentLength() returns a length of only 0.134 units, which is definitely wrong. And if I pass the same segment index to a and b, the returned length is always zero.

Are a and b rather point indexes instead of segments?

Thanks for any tipps!

Greetings,
Jack

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/11/2009 at 06:47, xxxxxxxx wrote:

I also tried to use the SplineHelp class, but it can't be found.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/11/2009 at 06:58, xxxxxxxx wrote:

Another addition: I included "lib_splinehelp.h", so I can now use the SplineHelp class. Using its GetSegmentLength() function, I can get the length of a segment by just passing the segment's index. And it works!! 🙂

But one strange thing remains: I have a spline with only one segment. I call GetSegmentLength() on this one segment and it returns a length of 482.564 units, which sounds quite reasonable. Just to check this, I looked up the length of the same spline with Xpresso (ObjectNode -> SplineNode -> ResultNode) and there it returns 482.392 units.

Funny, isn't it?

Cheers,
Jack