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

    Mirror without duplicate using `MCOMMAND_MIRROR`

    Cinema 4D SDK
    s22 python
    3
    12
    2.0k
    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.
    • K
      kisaf
      last edited by Manuel

      Hello guys,
      It's something weird with MCOMMAND_MIRROR in S22.

      This script (thanks to m_adam) duplicates and mirrors the object.

      import c4d
      
      
      def main():
          # Checks if selected object is valid
          if op is None:
              raise ValueError("op is none, please select one object.")
      
          # Defines some general settings, take care MDATA_MIRROR_VALUE, MDATA_MIRROR_SYSTEM and MDATA_MIRROR_PLANE
          settings = c4d.BaseContainer()
          settings[c4d.MDATA_MIRROR_DUPLICATE] = True
          settings[c4d.MDATA_MIRROR_SELECTIONS] = True
          settings[c4d.MDATA_MIRROR_ONPLANE] = True
          settings[c4d.MDATA_MIRROR_WELD] = True
          settings[c4d.MDATA_MIRROR_TOLERANCE] = 0.01
      
          # Corresponds to MDATA_MIRROR_VALUE, MDATA_MIRROR_SYSTEM and MDATA_MIRROR_PLANE
          value = 1000.0
          system = 0 # 0 = Object, 1 = World
          plane = 1 # 0 = XY, 1 = ZY, 2 = XZ
      
          if not 0 <= system < 2:
              raise ValueError("System can only be 0 or 1")
      
          # Buffer position vector
          pos = c4d.Vector()
      
          # Calculates Local (Object) coordinates
          if system == 0:
              globalMatrix = op.GetMg()
              if plane == 0:
                  pos = globalMatrix.v3
              elif plane == 1:
                  pos = globalMatrix.v1
              elif plane == 2:
                  pos = globalMatrix.v2
      
              settings[c4d.MDATA_MIRROR_POINT] = globalMatrix.off + pos * value
              settings[c4d.MDATA_MIRROR_VECTOR] = pos
      
          # Calculates World coordinates
          elif system == 1:
              if plane == 0:
                  pos = c4d.Vector(0.0, 0.0, 1.0)
              elif plane == 1:
                  pos = c4d.Vector(1.0, 0.0, 0.0)
              elif plane == 2:
                  pos = c4d.Vector(0.0, 1.0, 0.0)
      
              settings[c4d.MDATA_MIRROR_POINT] = pos * value
              settings[c4d.MDATA_MIRROR_VECTOR] = pos
      
          # Send the Modeling Operation
          res = c4d.utils.SendModelingCommand(c4d.MCOMMAND_MIRROR,
                                              [op],
                                              c4d.MODELINGCOMMANDMODE_ALL,
                                              settings,
                                              doc)
      
          c4d.EventAdd()
      
      
      if __name__ == "__main__":
          main()
      
      
      

      However, if I change

      settings[c4d.MDATA_MIRROR_DUPLICATE] = True
      

      to

      settings[c4d.MDATA_MIRROR_DUPLICATE] = False
      

      Script doesn't make anything.
      In R20 it works.
      Is it ok? Is there any way to just mirror the object without duplicate it?

      P.S. Also, if I use Mirror (https://help.maxon.net/index.html#5633) with unchecked Duplicate Points everything works (in S22).

      Cinema 4D S22.118 Windows 10

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hi,

        this look like a bug, I've opened a bug report

        Cheers,
        Manue

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • K
          kisaf
          last edited by kisaf

          Hi, I've just tested this script in R23. It doesn't work 😞
          One of my own scripts cannot work without this function.
          Guys, you're really awesome! I love C4D, and hope you can fix it πŸ˜„

          May be I can help somehow? I can upload the example scene, if you need it.

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by

            hi,

            this will be probably fixed for futur updates but i doubt that this will be fixed for previous version.

            The only way to go is to create your own function to mirror the polygon. This can be really long if you want to support uvs, texture, selection tag etc.

            Sorry for the inconvenient.

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            K 1 Reply Last reply Reply Quote 0
            • K
              kisaf @Manuel
              last edited by

              @m_magalhaes
              Got it, thanks πŸ™‚

              1 Reply Last reply Reply Quote 0
              • K
                kisaf
                last edited by

                Hello guys,
                This bug is still exists in S24. I made a video to show how it worked before (R21) and now (S22, R23, S24).

                For test I used the script from this page. The only difference I made is decreased value from 1000.0 to 0. It's just for convenience.

                This script should mirrors selected object, when settings[c4d.MDATA_MIRROR_DUPLICATE] is False. It works in R21 and doesn't work in any late releases.
                Could you fix it? I'm still using R21 because of this bug 😞

                1 Reply Last reply Reply Quote 0
                • ManuelM
                  Manuel
                  last edited by

                  Hi,

                  our developers are aware of the bug and i can't say when it will be fixed. I understand it's not pleasant for you.

                  Cheers,
                  Manuel

                  MAXON SDK Specialist

                  MAXON Registered Developer

                  1 Reply Last reply Reply Quote 0
                  • K
                    kisaf
                    last edited by

                    Roger that, thanks again.
                    I wasn't sure that the developers were aware. Sorry for annoy you πŸ™‚
                    Cheers

                    1 Reply Last reply Reply Quote 0
                    • F
                      Fritz
                      last edited by

                      Hi kisaf,

                      if you switch in the SendModelingCommand from MODELINGCOMMANDMODE_ALL to MODELINGCOMMANDMODE_POLYGONSELECTION it should work until the mirror in object mode is fixed.

                      Regards
                      Fritz

                      K 1 Reply Last reply Reply Quote 1
                      • K
                        kisaf @Fritz
                        last edited by

                        @fritz thank you very much, it works!

                        1 Reply Last reply Reply Quote 0
                        • ManuelM
                          Manuel
                          last edited by

                          Hi,

                          I've missed that one, thanks a lot @Fritz

                          Cheers,
                          Manuel

                          MAXON SDK Specialist

                          MAXON Registered Developer

                          1 Reply Last reply Reply Quote 0
                          • ManuelM
                            Manuel
                            last edited by

                            Hi,

                            This have been fixe and will be available in a futur update.

                            Cheers,
                            Manuel

                            MAXON SDK Specialist

                            MAXON Registered Developer

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