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

    CalcSplineInsert working correctly?

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 591 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

      On 15/02/2017 at 01:08, xxxxxxxx wrote:

      hi there,
      here's a small project:
      there is a spline round command in c4d which you can use to make bezier splines out of linear splines.

      now the goal was to do the same in python with a points array to get a "smooth" splinedata object
      i'm not sure if i really understood the purpose of CalcSplineInsert,
      but as i understood, it should be exactly doing that if set to b-spline mode.

      problem is i dont get any tangent info at all in this code ....
      does anybody know what is wrong?

      pts = [ c4d.Vector(x1,y1,0), c4d.Vector(x2,y2,0), ... ] # point array as vectors (2d)
          pcnt = 6 # point reduction

      spld = c4d.SplineData()
          spld.DeleteAllPoints()
          spld.MakePointBuffer(pcnt)

      for i in range(pcnt) :
              offset = float(i) / (pcnt - 1)
              p = c4d.utils.CalcSplineInsert(offset, c4d.SPLINETYPE_BSPLINE, False, len(pts), pts)
              print "i=",i,"@",offset,"p=",p
              spld.SetKnot(i, p["resultPoint"],
                  interpol=c4d.CustomSplineKnotInterpolationBezier,
                  vTangentLeft=p["leftTangent"], vTangentRight=p["rightTangent"])

      ps ofc i wanna match the original points as close as possible 😉
      the spline should go through the original points and estimate the curvature

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

        On 15/02/2017 at 07:05, xxxxxxxx wrote:

        Hi,

        To get valid tangents back from CalcSplineInsert() a list of tangents has to be passed even if the spline type is B-Spline (the documentation seems wrong).

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

          On 15/02/2017 at 23:28, xxxxxxxx wrote:

          hm yes,
          otherwise there is a bug in it.

          the point is that i don't have the tangents because the input spline is linear

          the round command in the spline menu can do it,
          so i thought there is some way to get that in python, too.
          (find soft splines through input points)

          CalcSplineTangent delivers tangent vectors with a linear input spline,
          but its only one vector per point,
          and i dont know how to get leftTangent and rightTangent from it...

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

            On 16/02/2017 at 00:54, xxxxxxxx wrote:

            ps.

            fyi, SplineData.SetType() is missing in the python docs
            it exists tough

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

              On 16/02/2017 at 07:33, xxxxxxxx wrote:

              Thanks for reporting that SplineData.SetType() is not documented.

              I'm really confused by your question.
              You mention Round command that works with Spline objects (3D spline) but you want to use CalcSplineInsert() with a SplineData (2D spline).

              I think you can simply change the interpolation type of all SplineData knots to CustomSplineKnotInterpolationBezier with SplineData.SetKnot().

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

                On 16/02/2017 at 07:57, xxxxxxxx wrote:

                ... i have :
                a linear input, a 2d curve described by points, tangents are unknown.

                ... i want:
                a soft spline going through these input points,
                best with a point reduction
                in a splinedata object

                i mentioned the round function for spline objects only because it does (kind of) what i want to do:
                you can draw a linear spline with 15 points using the pen tool, then use round tool with 5 points
                and you get a soft spline following these original points, but with a reduced point count of 5pts

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