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

    How to copy objects from docs

    Scheduled Pinned Locked Moved PYTHON Development
    8 Posts 0 Posters 764 Views
    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.
    • H Offline
      Helper
      last edited by

      On 12/02/2013 at 07:01, xxxxxxxx wrote:

      Dear users,

      I want to copy a object from one document to my new document, ¿how i do that?.

      I know the object´s name and the document´s root, i use a CommandData plugin.

      Thanks.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 12/02/2013 at 07:14, xxxxxxxx wrote:

        copyme = doc.SearchObject('myobj')
        root   = otherodc.SearchObject('myroot')
          
        copyme.InsertUnderLast(root)
        

        but names are a really bad way to get hold of an object. you should use reference guis like
        the linkbox or the inexclude list or use the with r14 newly introduced GUID / UIP of a BaseObject.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 12/02/2013 at 07:18, xxxxxxxx wrote:

          Ferdinand, you need to clone the object before you insert it from there, or remove it from the
          previous document. 🙂

          -Niklas

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 12/02/2013 at 07:30, xxxxxxxx wrote:

            ¿I have to open the other document before to copy the object using LoadDocument()?

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 12/02/2013 at 07:35, xxxxxxxx wrote:

              of course.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 12/02/2013 at 11:50, xxxxxxxx wrote:

                I have this error: "AttributeError: 'NoneType' object has no attribute 'SearchObject'" with this code:
                 
                objetc="Brillante"
                base=documents.LoadDocument(File,c4d.SCENEFILTER_OBJECTS)
                copy=base.SearchObject(objetc).GetClone()
                doc.InsertObject(copia)
                 
                "File" is the root of the base document.
                 
                Thanks

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 12/02/2013 at 11:59, xxxxxxxx wrote:

                  file needs to be an absolute document path string -> 'C:\Files\mydocument.c4d'. LoaDocument 
                  returns None when the given path does not exist. Therefore base is of the type None in your 
                  example.

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    On 12/02/2013 at 12:02, xxxxxxxx wrote:

                    Thanks ferdinand

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