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

    Identify the Return Objects from the Built-in Plug-in Tool

    Cinema 4D SDK
    r20 python
    2
    3
    451
    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 mirror a joint chain using the built-in Mirror Tool. I want the return for the function to be the mirrored joint. For instance, if I selected the joint chain thigh_L_jnt, I want the return/result of the function to be thigh_R_jnt. Currently, it returns nothing.

      Is there a way around this?

      You can see the code here:

      def mirror(objList):
      
          for idx, obj in enumerate(objList):
              if idx == 0:
                  doc.SetActiveObject(obj, mode=c4d.SELECTION_NEW)
              else:
                  doc.SetActiveObject(obj, mode=c4d.SELECTION_ADD)
      
          toolID = 1019953 # Mirror Tool ID
          c4d.CallCommand(toolID)
      
          tool = c4d.plugins.FindPlugin(toolID, c4d.PLUGINTYPE_TOOL)
          tool[c4d.ID_CA_MIRROR_TOOL_AXIS]    = 4 # XZ 
          tool[c4d.ID_CA_MIRROR_TOOL_REPLACE] = '_L_'
          tool[c4d.ID_CA_MIRROR_TOOL_WITH]    = '_R_'
      
          result = c4d.CallButton(tool, c4d.ID_CA_MIRROR_TOOL)
          return result # this returns nothing. 
      
      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @bentraje

        Actually, there is no way to retrieves the created object from the built-in Tool since CallButton is the same as if a user presses the button. So it's return nothing it simply processes the tool and inserts the needed stuff. Of course, you can check what's the behavior of this tool and how new objects are inserted.

        However, for most of the tool use SendModelingCommand which is an API around tool available which will give you all need. Setting coordinate system using MCOMMAND_MIRROR provides an example for MCOMMAND_MIRROR.

        If you have any questions, let me know.
        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 2
        • B
          bentraje
          last edited by

          RE: there is no way to retrieves the created object from the built-in Tool
          Thanks for the confirmation

          RE: SendModelingCommand/MCOMMAND_MIRROR.
          Correct me if I'm wrong but this works only on polygon objects. I'm mirroring a joint chain rather than a polygon object.

          Is there a way around this?

          Thank you.

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