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

    Export a single object

    SDK Help
    0
    5
    464
    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 29/07/2014 at 05:29, xxxxxxxx wrote:

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

      ---------
      I would like to export a single object to disk, in .OBJ format.
      To export in .OBJ format I can use the SaveDocument command, I believe.
      But to save just one object, not the entire scene, must I create a temporary document and save that? Should I use the IsolateObjects command to do so?

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

        On 29/07/2014 at 07:13, xxxxxxxx wrote:

        Hello Rui,

        i did the same thing once and i did i just created a temp document and inserted the object into it, then exported the temp doc into the desired file-format.

        I have never used IsolateObjects yet, but it looks like it does the same thing, so it should work as well.

        greets,
          Daniel

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

          On 29/07/2014 at 07:44, xxxxxxxx wrote:

          Thank you very much, Daniel. I will try it out, as soon as I get back from vacation.

          Rui Batista

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

            On 29/07/2014 at 08:25, xxxxxxxx wrote:

            Hi,

            i just checked my code from back then and it looks like i actually *did* use the IsolateObjects function..

            here's an example of how it should work:

                
                
                static void exportSelected(BaseDocument* doc, Filename exportFileName){	
                	if(!doc) return;
                 
                	// get all selected objects		
                	AtomArray* ar = AtomArray::Alloc();
                	doc->GetActiveObjects(*ar,TRUE);
                	if(ar->GetCount()<1) return;
                 
                	// copy all objects in Array 'ar' to tmpDoc
                	BaseDocument* tmpDoc = IsolateObjects(doc,*ar);
                 
                	// save doc to file
                	if(tmpDoc){				
                		if(SaveDocument(tmpDoc,exportFileName,SAVEDOCUMENTFLAGS_0,FORMAT_OBJEXPORT)){
                			GePrint("exported selected objects to file "+exportFileName.GetFileString());
                		}
                		else GePrint("could not export selected objects to file "+exportFileName.GetFileString());
                	}
                }
            
            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 29/07/2014 at 09:12, xxxxxxxx wrote:

              WOW! Great. Your code will be of great help.
              Thank you, Daniel.

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