Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Toggle knife cut planes

    Cinema 4D SDK
    r21 python
    2
    4
    621
    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.
    • P
      peXel
      last edited by Manuel

      Hello There,

      in earlier days (R19 and before) I had a script to toggle the planes from our plane knife cut tool. Sadly it's not working anymore (R21).
      What I was able to create was a simple plane cut script for each plane, but I need now three shortcuts to switch them instead of one.
      Does anybody have an idea, how this script will look like, with one shortcut?

      Thank you very much!

      Best,
      Peter

      import c4d
      from c4d import gui
      
      def main():
          def tool():
              return c4d.plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL)
      
          def object():
              return doc.GetActiveObject()
      
          def tag():
              return doc.GetActiveTag()
      
          def renderdata():
              return doc.GetActiveRenderData()
      
          def prefs(id):
              return c4d.plugins.FindPlugin(id, c4d.PLUGINTYPE_PREFS)
      
          c4d.CallCommand(431000164, 431000164) # Plane Cut
          tool()[c4d.MDATA_KNIFEPLANE_PLANE_MODE] = 2
          tool()[c4d.MDATA_KNIFEPLANE_PLANE] = 0
      
      if __name__=='__main__':
          main()
          c4d.EventAdd()
      
      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hello,

        if i understood correctly the question you should just add one the to current value of the MDATA_KNIFEPLANE_PLANE with a % (modulo) of 3. So the value will come back to 0 instead of going to 4.

            tool()[c4d.MDATA_KNIFEPLANE_PLANE] = (tool()[c4d.MDATA_KNIFEPLANE_PLANE] + 1) % 3
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • P
          peXel
          last edited by Manuel

          @m_magalhaes PERFECT! thank you very much!

          import c4d
          from c4d import gui
          
          def main():
              def tool():
                  return c4d.plugins.FindPlugin(doc.GetAction(), c4d.PLUGINTYPE_TOOL)
          
              def object():
                  return doc.GetActiveObject()
          
              def tag():
                  return doc.GetActiveTag()
          
              def renderdata():
                  return doc.GetActiveRenderData()
          
              def prefs(id):
                  return c4d.plugins.FindPlugin(id, c4d.PLUGINTYPE_PREFS)
          
              c4d.CallCommand(431000164, 431000164) # Plane Cut
           tool()[c4d.MDATA_KNIFEPLANE_PLANE] = (tool()[c4d.MDATA_KNIFEPLANE_PLANE] + 1) % 3
          
          if __name__=='__main__':
              main()
              c4d.EventAdd()
          
          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by

            i forgot to mention:

            For your next threads, please help us keeping things organised and clean. I know it's not your priority but it really simplify our work here.

            • Q&A New Functionality.
            • How to Post Questions especially the tagging part.

            I've added the tags and marked this thread as a question so when you considered it as solved, please change the state 🙂

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • ferdinandF ferdinand referenced this topic on
            • First post
              Last post