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

    c4DAtom::CopyTo() and AliasTrans

    SDK Help
    0
    4
    479
    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
      Helper
      last edited by

      On 26/09/2013 at 06:34, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   13.061 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hello,
       
      I like to copy some objects from one c4d project into another project. I open a second project with LoadDocument(...) and now I can scan all objects. I'm create new objects in my project and use the CopyTo(..) function to copy all data (BaseContainer and tags) to my object in my project. That's working.
      But in some BaseContainers are LINKs inside with references to other objects. The CopyTo(..) function can not copy this links simple. I'm reading something about the AliasTrans parameter, but I don't understand how this is working. Or what I have to implement it. How convert C4D the links into my project?
       
      regards
      Markus

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

        On 26/09/2013 at 09:34, xxxxxxxx wrote:

        Allocate (AutoAlloc will work) an AliasTrans and include it in the CopyTo.  This class is then tasked by the call to 'fix' the links.  The docs for AliasTrans provide an example:

        AutoAlloc<AliasTrans> aliastrans;  
        if (!aliastrans || !aliastrans->Init(document)) return FALSE;  
        dup = op->GetClone(COPYFLAGS_0, aliastrans);  
        if (!dup) return FALSE;  
        aliastrans->Translate(TRUE);
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 26/09/2013 at 22:29, xxxxxxxx wrote:

          Does it means, I have to implement the Translate() function itself?
          Because if I added this code, nothing happend with the links. All links in BaseContainer are empty. !Cry[URL-REMOVED]
           
          I add a part of my code: (it's only a clip)
           
           ...
           BaseDocument* pXrefDoc = LoadDocument(file, SCENEFILTER_OBJECTS | SCENEFILTER_MATERIALS, NULL); 
           BaseObject *pobj = pxrefdoc->GetFirstObject();
           
           AutoAlloc<AliasTrans> aliastrans;
           if (!aliastrans || !aliastrans->Init(pdoc)) return;
           while ( pXrefobj ) {
            C4DAtom * atom;
            BaseObject* poNew;
            //if (!pXrefobj->CopyTo( poNew, COPYFLAGS_0, aliastrans )) return;       // copy base container data and tags, but no links
            atom = pXrefobj->GetClone( COPYFLAGS_0, aliastrans );
            if (!atom) return;
            aliastrans->Translate( TRUE );
            poNew = (BaseObject* )atom;
            poNew->SetName( "My::"+ pXrefobj->GetName());    // set name with namespace
            pdoc->InsertObject( poNew, NULL, ppred );
            pXrefobj = pXrefobj->GetNext();
           }
           ...


          [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

            On 27/09/2013 at 00:26, xxxxxxxx wrote:

            You probably need to postpone the aliastrans->Translate() call until after the loop so that all of the objects that are linked exist in (have been inserted into) the document for translation.  If one AliasTrans fails, you might need an array of them (one for each clone).

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