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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    GetSegmentCount() always returns 1?

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 730 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 11/04/2011 at 10:22, xxxxxxxx wrote:

      Hi,

      I'm testing the SplineHelper class functions. But for some reason GetSegmentCount() always returns the value of one. Even though my spline has multiple segments.
      Any idea what I'm doing wrong here?:

        
      import c4d  
      from c4d import gui  
        
      def main() :  
        
       sh = c4d.utils.SplineHelp()  
       sh.InitSpline(op, rail=None, target_rail=True, use_deformed_points=True, force_update=True, use_global_space=True)  
       segCount = sh.GetSegmentCount()#Counts the total number of segments  
       segLength = sh.GetSegmentLength(0)#Gets the length of the first segment   
       totalLenght = sh.GetSplineLength()#Gets the length of the entire spline  
          
       print segCount  
       print segLength  
       print totalLenght   
        
      if __name__=='__main__':  
        main()  
      

      -ScottA

      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 11/04/2011 at 11:16, xxxxxxxx wrote:

        It returns '2' here which is the correct value.
        This is the spline I've tested:

        Cheers, Niklas

        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 11/04/2011 at 12:01, xxxxxxxx wrote:

          Doh!

          I guess I got confused about how these classes decide what a "segment" is.
          After looking through my Coffee notes. I realized that what I was trying to do required using the SplineLengthData class.
          Not the SplineHelp class.

          Like this:

            
          import c4d  
          from c4d import gui  
            
          def main() :  
            length = c4d.utils.SplineLengthData(op[0])#Creates a new instance of the SplineLengthData class  
            length.Init(op,0)# Initializes the spline object(op) and the first spline segment  
            print(length.GetLength())# The Spline's Length  
            print(length.GetSegmentLength(0,1))#The first segment's length  
            length.Free()#free up the memory used by the new SplineClass instance  
            
          if __name__=='__main__':  
            main()  
          

          -ScottA

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