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

    VectorPosition on Spline?

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 759 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 22/06/2011 at 02:41, xxxxxxxx wrote:

      Does any kind soul know how to get the vector position for a spline using Py?
      I have spent all night without any luck and cannot for the life of me
      manage to get it.
      In coffee I do as shown but whatever I try in Python can't get past
      the init part as I don't understand what class does what.

        
      var splineobject = object(); // a selected splineobject   
      var realspline   = splineobject->GetRealSpline(); // the realspline   
      var sldata       = new(SplineLengthData); // the data to use   
          sldata->Init(realspline,0); // the init spline first segment   
      var pos          = realspline->GetSplinePoint(0.5,0); // The vector position in space at 50% of segment   
      

      Cheers
      Lennart

      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 22/06/2011 at 02:59, xxxxxxxx wrote:

        I don't see the difference between a SplineObject and a LineObject, but they can both be used with the c4d.utils.SplineHelp class.
        Try this:

        import  c4d  
        from    c4d.utils    import SplineHelp  
          
        def main() :  
          if op is None:  
              print "No object selected."  
              return  
          
          if not op.CheckType(c4d.Ospline) :  
              print "No splineobject. Retrieving Cache ..."  
              globals()["op"]     = op.GetCache()  
          
          if not op.CheckType(c4d.Oline) and not op.CheckType(c4d.Ospline) :  
              print "Cache is not a line- or splineobject."  
              return   
          
          
          shelp   = SplineHelp()  
          shelp.InitSpline(op)  
          
          _range  = 20  
          _range  = float(_range)  
          for i in xrange(int(_range) + 1) :  
              i   = i / _range  
              pos     = shelp.GetPosition(i)  
              print str(i).ljust(5), ":", pos  
          
        main()
        

        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 22/06/2011 at 03:04, xxxxxxxx wrote:

          Thanks Niklas, will look into it right away.
          (Also many thanks for the Cyclebutton example earlier,
          now I get attributes to work instead of using Userdata!)

          Cheers
          Lennart

          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 22/06/2011 at 04:05, xxxxxxxx wrote:

            Oh, I got it (Needed some sleep 🙂 )
            I didn't realize that I needed to import SplineLengthData from c4d.utils.

            Niklas, I think what you wonder is within SplineLengthData()
            as it gets whatever spline is thrown at it.

            Now it works the same as my coffee example.

              
            import c4d   
            from c4d import utils   
            from c4d.utils import SplineHelp, SplineLengthData   
              
            def main() :   
                obj = op.GetObject()   
                rs = obj.GetRealSpline()   
                if rs is False:   
                    print 'No'   
                    return False   
                   
                sdata = SplineLengthData()   
                sdata.Init(rs,0)   
                pos = rs.GetSplinePoint(0.5,0)   
                sdata.Free()   
                print pos   
            

            Cheers
            Lennart

            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 22/06/2011 at 04:09, xxxxxxxx wrote:

              Corrected code for checking if spline object, should be "None", not False.

                
              import c4d   
              from c4d import utils   
              from c4d.utils import SplineHelp, SplineLengthData   
                
              def main() :   
                  obj = op.GetObject()   
                  rs = obj.GetRealSpline()   
                  if rs is None:   
                      print 'Not a Spline'   
                      return False   
                     
                  sdata = SplineLengthData()   
                  sdata.Init(rs,0)   
                  pos = rs.GetSplinePoint(0.5,0)   
                  sdata.Free()   
                  print pos   
              

              Cheers
              Lennart

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