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

    How to adress the mograph cloner offset in the attached python code please :)

    Cinema 4D SDK
    3
    3
    408
    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.
    • O
      Ofcourse88
      last edited by

      import c4d
      
      def main():
          global traveled
          global lastPos
      
          obj = op.GetObject()
          objMat = obj.GetMg()
          frame = doc.GetTime().GetFrame(doc.GetFps())
          forwardVec = objMat.MulV(c4d.Vector(1.0, 0.0, 0.0))
          sign = 1.0
      
          try: lastPos
          except NameError:
              lastPos = obj.GetMg().off
          try: traveled
          except NameError:
              traveled = 0
      
          if frame == 0:
              traveled = 0
              lastPos = objMat.off
          else:
              currentPos = objMat.off
              # calculate actual movement
              distVec = currentPos - lastPos
              dotProd = distVec.Dot(forwardVec)
              if dotProd > 0: sign = -1.0
              projVec = forwardVec * dotProd
              dist = projVec.GetLength()
              lastPos = currentPos
              traveled = traveled + sign * dist
          # find the material
          mat = obj.GetTag(c4d.Ttexture)
          mat[c4d.TEXTURETAG_OFFSETX] = traveled / 500.0
          # the factor depends on the texture and the obje
      

      Hello, how to adress the Mograph cloner offset (cloner is set to object (spline) and i want just to edit the part in the code

      mat[c4d.TEXTURETAG_OFFSETX] = traveled / 500.0
      

      and make it work, but i am affraid i will need to edit more, for example to find the object. I am noob about python or any language, so could you help me someone please 🙂

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

        Hi @Ofcourse88 welcome in the plugincafe community

        I didn't understand what's your problem, can you try to explain what you exactly want to do, and in which context are you (script editor, Python generator, python tag?)

        If you want to change the Mograph Cloner offset parameter value, then doing

        op[c4d.MG_SPLINE_OFFSET] = 0.5
        

        Will set the currently selected cloner to 0.5.

        To know parameter id, you can use the console for more information see Console - Drag and Drop.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • CairynC
          Cairyn
          last edited by

          I just answered this on CGSociety, as the thread was started there:

          https://forums.cgsociety.org/t/help-with-the-simple-but-advanced-rig-at-the-same-time-with-xpresso-or-python-i-am-talking-about-tank-belts/2058564/12

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