Scale spline range



  • On 09/08/2013 at 12:17, xxxxxxxx wrote:

    Hi guys. Tough quesstion.

    I have two splines - TOP ir the one that user may adjust, and BOTTOM that is automatically generated from TOP spline, BUT scaled to 30% on x axis? If user adds a point on TOP spline at 50%, it should automatically be added on BOTTOM spline at 50%*30%

    Basically what I am looking for is a way to change range or scale overall spline on X axis. I hope you understand. Cheers.



  • On 09/08/2013 at 12:33, xxxxxxxx wrote:

    Get the SplineData of the top spline. Clone the SplineData. Update each point in the SplineData clone by scaling the axis components with their scaling factors. Write the SplineData clone back into your GUI. The place to invoke that process can either be the NodeData.Message() method, while listening for the ID DESCRIPTION_BLAH_SOMETHING_UPDATE, or the NodeData.GetDEnabling() method.



  • On 09/08/2013 at 12:40, xxxxxxxx wrote:

    All sound very nice until "Update each point in the SplineData clone" - how would I do that? How to access those points?

    Isn't there a simpler way? Something like copy original GUI, scale it by factor X, paste that to new GUI. No?



  • On 09/08/2013 at 12:49, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Something like copy original GUI, scale it by factor X, paste that to new GUI. No?

    That is exactly what I did suggest in my first posting. The only difference is that you cannot scale the SplineData as an object, but you have to do it per point/tangent. Read the Sdk, there are some inconsistencies in the SplineData documentation, but the relevant information is there. The method for your task should be SetKnot for overwriting the SplineKnots and GetKnots to get the existing knot data. Here is a snippet on how to write knots into a SplineData instance:

    rampSpl, rmpCount = c4d.SplineData(), 7
    rampSpl.MakePointBuffer(rmpCount)
    step = 1.0/ (rmpCount-1)
    for i in xrange(rmpCount) :
        if i == 0:
            rampSpl.SetKnot(index = i, vPos = c4d.Vector(i * step, (i * step) ** 5, 0), interpol = 1)
        elif i >= rmpCount-2:
            rampSpl.SetKnot(index = i, vPos = c4d.Vector(i * step, (i * step) ** 5, 0), interpol = 1)
        else:
            rampSpl.SetKnot(index = i, vPos = c4d.Vector(i * step, (i * step) ** 5, 0), interpol = 2)
    

Log in to reply