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

    Rendering to a temp Document?

    SDK Help
    0
    5
    455
    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 08/09/2013 at 12:35, xxxxxxxx wrote:

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

      ---------
      Hi,

      I'm trying to figure out how to render things to a temporary document while I'm working on the scene.
      I can clone the active document like this: BaseDocument *tmpDoc = doc->Polygonize(TRUE);

      But how do I execute the rendering to the picture viewer in that temp document?

      -ScottA

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

        On 08/09/2013 at 13:07, xxxxxxxx wrote:

        You can trigger the "Render to Picture Viewer" button. Afaik there is no direct way to simulate this
        command from the SDK. Using RenderDocument() with the RENDERFLAGS_CREATE_PICTUREVIEWER
        only shows the picture after it has actually been rendered.

        You do not even have to polygonize the document. If at all, you need to create a copy. But if you 
        already have a clone of the document from somewhere, you can tell RenderDocument() not to
        re-clone the document because you already did by passing RENDERFLAGS_NODOCUMENTCLONE.

        Best regards,
        -Niklas

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

          On 08/09/2013 at 14:06, xxxxxxxx wrote:

          The problem I'm running into is that If I try to execute anything. It will execute in the document I'm working in. Not the temp doc.
          I need a way to tell the temp doc to trigger the RPV command. Not the doc I'm working in.

          I was able to get the temp doc to render using RenderDocument().
          But like you said. It only returns the last frame. But worse than that...It locks up the current document I'm working in. Due to threading.
          So I guess using a temp doc isn't really going to do what I want.

          This is what I'm doing by hand manually. That I'm trying to do with code:
          -Make a copy of my current scene (document)
          -Execute the RPV rendering in the copy
          -Go back to the original scene and continue working. While the other document is rendering.

          There's no threading problems when I use this workflow. Because they are two different documents.
          But I'm having a devil of a time automating this workflow.

          What do you recommend I use for copying the document Niklas?

          -ScottA

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

            On 08/09/2013 at 15:54, xxxxxxxx wrote:

            Originally posted by xxxxxxxx

            This is what I'm doing by hand manually. That I'm trying to do with code:
            -Make a copy of my current scene (document)
            -Execute the RPV rendering in the copy
            -Go back to the original scene and continue working. While the other document is rendering.

            These are actually the exact steps I do in my PV Render Queue plugin. It is a nasty
            workaround, but I couldn't find another way to simulate the "Render to Picture Viewer" button
            than to actually call it.

            A snippet from my plugin's source code:

                CMD_RENDERPV = 12099
            
            
              
            
            
            
                def RenderFile(self, file\_) :
                    file\_.done = True
            
                    flags = c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS
                    doc = c4d.documents.LoadDocument(file\_.filename, flags)
                    if not doc:
                        print "Document could not be opened:", file\_.filename
                        return
            
                    active_doc = c4d.documents.GetActiveDocument()
                    c4d.documents.InsertBaseDocument(doc)
                    c4d.documents.SetActiveDocument(doc)
                    c4d.CallCommand(CMD_RENDERPV)
                    c4d.documents.KillDocument(doc)
            
                    if active_doc() :
                        c4d.documents.SetActiveDocument(active_doc)
            

            Instead of loading a new document, you'd create a clone.

            Best regards,
            -Niklas

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

              On 08/09/2013 at 16:36, xxxxxxxx wrote:

              Thanks for posting that code Nik.
              After thinking about it some more. I think that's really pretty much sufficient for my needs.
              And I don't really need to get any fancier with it than that right now.

              Here's the C++ version I'm using:

                  Filename name = doc->GetDocumentName();    //Gets the name & extesion  of the document without the path  
                Filename path = doc->GetDocumentPath();      //Gets the file's path, minus the file's name and extension  
                String fullPath = path.GetString() + "\\" + name.GetString();   //Combine them to get the full file path  
                
                //Save the scene before we open it back up and render it  
                //This lets us change the scene and get accurate rendering results  
                SaveDocument(doc, fullPath, SAVEDOCUMENTFLAGS_0, FORMAT_C4DEXPORT);  
                
                //Open the scene   
                BaseDocument *docCopy = LoadDocument(fullPath, SCENEFILTER_OBJECTS | SCENEFILTER_MATERIALS, NULL);  
                
                //Insert the scene into the CINEMA editor list of documents  
                InsertBaseDocument(docCopy);  
                SetActiveDocument(docCopy);  
                CallCommand(12099);        //Render to picture viewer  
                KillDocument(docCopy);
              

              Thanks for the help.
              I was making it a lot more complicated than it needed to be.

              -ScottA

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