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

    Scale spline range

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 476 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 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.

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

        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.

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

          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?

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

            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)
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post