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

    Unexpected Spline Behavior on Creating IK Spline Tag

    Cinema 4D SDK
    r20 python
    2
    3
    566
    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.
    • B
      bentraje
      last edited by

      Hi,

      I'm trying to create an IK Spline Tag with an existing spline/curve object.
      The problem is whenever I run the code, the spline interpolation is replaced.
      You can see an illustration video of the problem here:
      https://www.dropbox.com/s/50thcrfnaepme3z/c4d091_spline_interpolation_maintain.mp4?dl=0

      You can check the illustration file here:
      https://www.dropbox.com/s/fgkfh8jg7624z4l/c4d091_spline_interpolation_maintain.c4d?dl=0

      Is there a way around this?

      Thank you for looking at the problem.

      Here is the code I used:

      import c4d
      
      def list_children(obj, withParent=1):
          if withParent:
              objList = [obj]
          else:
              objList = []
      
          for kid in obj.GetChildren():
              objList += list_children(kid)
          return objList
      
      def torso_spline():
          spine_chain = list_children(doc.SearchObject("spine01_jnt"))
      
          start_ikHandle = c4d.BaseObject(c4d.Onull)
          start_ikHandle.SetMg(spine_chain[0].GetMg())
          start_ikHandle.SetName( (spine_chain[0].GetName()) + "_ikHandle" )
          doc.InsertObject(start_ikHandle)
      
          end_ikHandle = c4d.BaseObject(c4d.Onull)
          end_ikHandle.SetMg(spine_chain[6].GetMg())
          end_ikHandle.SetName( (spine_chain[6].GetName()) + "_ikHandle" )
          doc.InsertObject(end_ikHandle)
      
          spine_crv = doc.SearchObject("spine_crv")
          
          # Create IK Spline tag
          
          ikSpline_tag = spine_chain[0].MakeTag(1019862)
          doc.AddUndo(c4d.UNDOTYPE_NEW, ikSpline_tag)
             
          ikSpline_tag[c4d.ID_CA_IKSPLINE_TAG_SPLINE]    = spine_crv    # error in this. it changes the curve. 
          ikSpline_tag[c4d.ID_CA_IKSPLINE_TAG_END]       = spine_chain[6]
          ikSpline_tag[c4d.ID_CA_IKSPLINE_TAG_TYPE]      = c4d.ID_CA_IKSPLINE_TAG_TYPE_EQUAL
          
          # Add IK handles
          
          c4d.CallButton(ikSpline_tag, c4d.ID_CA_IKSPLINE_HANDLE_ADD)
          c4d.CallButton(ikSpline_tag, c4d.ID_CA_IKSPLINE_HANDLE_ADD)
          
          ikSpline_tag[10002] = start_ikHandle
          ikSpline_tag[10012] = end_ikHandle
      
      torso_spline()
      c4d.EventAdd()
      
      1 Reply Last reply Reply Quote 0
      • B
        bentraje
        last edited by

        Kindly ignore the query above.
        I think this is more of a rigging question rather than a coding questing.
        Anyhow, in the IK spline tag, if you set the align and aim axis to X rather than default Z.
        And set the offset from 10cm to like 50cm.

        It should work more or less as expected.

        Thanks!

        1 Reply Last reply Reply Quote 0
        • M
          m_adam
          last edited by

          Hi @bentraje, since you rotate the axis (with SetMg) you also need to update the tangents according to the correct axis since tangents are in local space of points positions which are also in local space of the object.

          But as you figured is more rigging than a programming issue. And if you already solve the issue congratz! 😉

          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

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