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

    Make Objects Editable (Streamlined)?

    Cinema 4D SDK
    r20 python
    2
    5
    1.4k
    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 understand that there is a working script from Donovan Keith in this thread.

      In his script, he uses GetClone. I'm guessing to have another copy of the object.
      I'm trying to rewrite the script without using the GetClone method.

      Is this possible?

      Here is my script so far:

      import c4d
      from c4d import utils
      
      res = c4d.utils.SendModelingCommand(
                                    command = c4d.MCOMMAND_MAKEEDITABLE,
                                    list = op,
                                    mode = c4d.MODELINGCOMMANDMODE_ALL,
                                    doc = doc )
      c4d.EventAdd()
      

      With this script, it gives me an error of
      TypeError: GeListNode_mp_subscript expected Description identifier, not long

      Did a google search but it doesn't give me any relevant hits.

      Is there a way around this?

      Thank you for looking at my problem

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

        hello,

        seem that you forgot brackets on your list of object.

        list = [op]
        

        watch out where you are running those command, some operation have to be executed in the main thread
        on a script it should look like this

        import c4d
        from c4d import gui
        from c4d import utils
        # Welcome to the world of Python
        
        
        # Script state in the menu or the command palette
        # Return True or c4d.CMD_ENABLED to enable, False or 0 to disable
        # Alternatively return c4d.CMD_ENABLED|c4d.CMD_VALUE to enable and check/mark
        #def state():
        #    return True
        
        # Main function
        def main():
        
            op = doc.GetActiveObject()
        
            if not op: 
                raise TypeError("there's no object selected")
            res = utils.SendModelingCommand(
                                      command = c4d.MCOMMAND_MAKEEDITABLE,
                                      list = [op])
            #check if res is a list 
            if res is False:
                raise TypeError("make editable didn't worked")
            elif res is True:
                print "make editable should not return true"
            elif isinstance(res, list):
                doc.InsertObject(res[0])
            
            
            c4d.EventAdd()
        
        # Execute main()
        if __name__=='__main__':
            main()
        

        Cheers
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

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

          @m_magalhaes

          Thanks Manuel! Works as expected. Didn't expect that you had to add brackets. That was news to me.

          Thanks again!

          P.S. You also need to add brackets on your example.

          Have a great day ahead!

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

            i don't know what you are talking about 😇

            MAXON SDK Specialist

            MAXON Registered Developer

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

              Just to add some side notes :

              SendModelingCommand is waiting for a list of objects in case you want to execute that command on several objects.

              In your case, you only got one element in your list.

              You can have more informations about list here

              MAXON SDK Specialist

              MAXON Registered Developer

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