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

    Freeing Loaded BaseDocument

    SDK Help
    0
    3
    372
    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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 27/08/2003 at 18:25, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   8.100 
      Platform:      Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      I'm writing a file-animation plugin (ie one which loads a different file per frame), and everything works fine until I try to free the document I've loaded.

      I've tried using BaseDocument::Free() and also ::KillDocument(), but both crash C4D.

      Here's the relevant bit of code:

        
      class FileAnim : public ObjectData  
      {  
      // ...                                                                         
      BaseDocument* _anidoc; // initted to 0 in FileAnim()                            
      };  
        
      BaseObject*  
      FileAnim::GetVirtualObjects(PluginObject* op, HierarchyHelp* hh)  
      {  
      Filename filenm;  
      // ...                                                                         
      // cache not valid: must load new file                                          
      if (_anidoc)  
          {  
            // HELP! both of these will crash us!                                      
            ::KillDocument(_anidoc);  
            BaseDocument::Free(_anidoc);  
          }  
      _anidoc = ::LoadDocument(filenm, true /*showerrors*/);  
      return _anidoc->GetFirstObject();  
      }  
      

      How should I be freeing the loaded document?

      Thanks.

      .angus.

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 28/08/2003 at 00:46, xxxxxxxx wrote:

        You should remove the objects from the document before passing them from GetVirtualObjects(), then from your document. Only the first object and all children will be passed out using that method btw.

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 28/08/2003 at 18:23, xxxxxxxx wrote:

          Thanks David.
          Now looks something like the following and works a treat.

            
          // ...                                                                         
          // cache invalid                                                                
          BaseDocument* anidoc = ::LoadDocument(filenm, true /*showerrors*/);  
          BaseObject* aniroot = BaseObject::Alloc(Onull);  
          BaseObject* obj = anidoc->GetFirstObject();  
          for ( ; obj; obj = obj->GetNext())  
              {  
                obj->Remove();    // remove from anidoc                                     
                obj->InsertUnderLast(aniroot);  
              }  
          BaseDocument::Free(anidoc);  
          return aniroot;  
          

          .angus.

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