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
    • Register
    • Login

    MCOMMAND_JOIN issue

    Cinema 4D SDK
    python
    4
    10
    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.
    • merkvilsonM
      merkvilson
      last edited by r_gigante

      Hello PluginCafe 🙂

      I need to merge 2 objects in OBJECT_GENERATOR plugin and return the result but it returns only 1 object. my code looks like this. Am I doing something wrong?

      import c4d, os
      from c4d import plugins, utils, Vector as v
      
      class Otest(c4d.plugins.ObjectData):
          def GetVirtualObjects(self, op, hh):
              
              virtualDoc = c4d.documents.BaseDocument()
      
              cube1 = c4d.BaseObject(c4d.Ocube)
              cube1.SetAbsPos(v(0,0,110))
              virtualDoc.InsertObject(cube1)
      
              cube2 = c4d.BaseObject(c4d.Ocube)
              cube2.SetAbsPos(v(0,0,-110))
              virtualDoc.InsertObject(cube2)
      
              virtualDoc.ExecutePasses(c4d.threading.GeGetCurrentThread(), True, True, True, c4d.BUILDFLAGS_INTERNALRENDERER)
              
              output = utils.SendModelingCommand(command = c4d.MCOMMAND_JOIN, doc = virtualDoc, list = [cube1,cube2])[0]
              return output
      
      if __name__ == "__main__":
          plugins.RegisterObjectPlugin(id = 1000000, 
                                       str = "Test", 
                                       g = Otest, 
                                       description = None, 
                                       info = c4d.OBJECT_GENERATOR, 
                                       icon = None)
      
      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @merkvilson; MCOMAND_JOIN have changed in R18, now objects have to be under the same hierarchy.
        See Behaviour of MCOMMAND_JOIN different in R18 or [Python] SendModelingCommand().

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 3
        • mikeudinM
          mikeudin
          last edited by

          You have to combine objects to null, for example:

          import c4d
          from c4d import gui
          
          def smc(listy):
              null = c4d.BaseObject(c4d.Onull)
          
              for o in listy:
                  o.InsertUnder(null)
          
              res = c4d.utils.SendModelingCommand(command = c4d.MCOMMAND_JOIN,
                                              list = [null],
                                              mode = c4d.MODELINGCOMMANDMODE_ALL,
                                              bc = c4d.BaseContainer(),
                                              doc = doc)
              return res[0]
          
          def main():
              obs = doc.GetActiveObjects(0)
              doc.InsertObject(smc(obs))
              c4d.EventAdd()
          
          if __name__=='__main__':
              main()
          

          Checkout my python tutorials, plugins, scripts, xpresso presets and more
          https://mikeudin.net

          1 Reply Last reply Reply Quote 3
          • merkvilsonM
            merkvilson
            last edited by

            Thanks guys!
            It worked!
            I had to double-check this in SDK 😁

            1 Reply Last reply Reply Quote 0
            • merkvilsonM
              merkvilson
              last edited by

              btw. is it possible to sort the search results by date? I was getting 8 years old posts when looking for this topic.

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

                For sure go to https://developers.maxon.net/forum/search (you can also access this page by clicking on the little bolts/nuts which appears after a click on the top search bar.)

                Then on this page, you can define more option to search, and you can decide which kind of sorting you prefer.

                Cheers,
                Maxime.

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

                merkvilsonM 1 Reply Last reply Reply Quote 2
                • merkvilsonM
                  merkvilson @m_adam
                  last edited by

                  Thanks, buddy. Will take this into account 👌

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

                    Finally please do not forget to mark your topic as solved. See Q&A Functionality 😉 .

                    MAXON SDK Specialist

                    Development Blog, MAXON Registered Developer

                    merkvilsonM 1 Reply Last reply Reply Quote 0
                    • merkvilsonM
                      merkvilson @m_adam
                      last edited by

                      @m_adam

                      I was looking for "Solved" option in tags section but could not find it.

                      Finally, I figured this out.
                      Seems like this is because my browser's zoom is set to 150%

                      alt text

                      1 Reply Last reply Reply Quote 0
                      • a_blockA
                        a_block
                        last edited by

                        Hi,
                        thanks for pointing out this issue. We'll see if can get a fix for that (not all tags visible, if zooming in with browser).
                        In the end Maxime wasn't referring to tags at all. Instead he was talking about the Q&A Function we have in this forum. I took the freedom to mark this thread as solved (see this shiny green stamp next to the headline ☺ ).
                        Cheers,
                        Andreas

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