CalcSplineInsert working correctly?

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()

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"],
            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

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


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).

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...

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


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

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().

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