How to copy objects from docs



  • 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.



  • 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.



  • 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



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

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



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

    of course.



  • 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



  • 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.



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

    Thanks ferdinand


Log in to reply