Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    How to use GetSegmentLength()

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 249 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post