multi passes to folder using render que



  • On 30/09/2014 at 13:59, xxxxxxxx wrote:

    I'm writing a project management plugin to help organize my files/renders. I'm adding each new scene to the render que and batch rendering from there. What I'd like to be able to do is after each individual scene is finished rendering automate the run of a script that puts each pass of my multi pass into it's own folder.

    I've seen Renomi which has the functionality I want, but I don't want to have to manually trigger the action each time, I just want the render job to finish and auto move the files.

    Is this possible? If so can someone point me in the right direction on how to accomplish this?



  • On 30/09/2014 at 15:34, xxxxxxxx wrote:

    Hi,

    as I´m writing something similar to work with some friends together.
    Try this one:

      
      
      BatchR = c4d.documents.GetBatchRender()  
      
      #just to check  
      BatchR.Open()  
      print BatchR.GetElementCount()  
      
      if BatchR.GetElementCount()==0:  
          print "no job in batchrender"  
          return  
      
      if BatchR.GetElementStatus(0) == c4d.RM_FINISHED:  
          print " job with id one is finished"  
          #do your sorting stuff  
      
      
    

    If you´ve figured out how to set up the ae file e.g that all the renamed folders and files where found,
    please contact me or post it if you like.
    I´m very interested in this topic.
    cheers,
    Martin



  • On 01/10/2014 at 09:34, xxxxxxxx wrote:

    Cool Thanks! I'll give that a go. As far as updating AE filepath I found this thing the other day:
    http://aescripts.com/batch-search-n-replace-paths/



  • On 25/12/2014 at 11:15, xxxxxxxx wrote:

    Couldn't you just update the compositing project file with new links?

    Still, this feature sounds a great implementation to Renomi. Will try to implement it. Thanks for idea.



  • On 06/01/2015 at 15:26, xxxxxxxx wrote:

    Hello Tomas,

    could you please post an example of your suggestion updating the composition file?

    You can simply run another thread with the renomi plugin in which you check if the rendering is still running.
    After the rendering is finished you can do the sorting stuff.

    it could be done better but this one as a starting point:

    import c4d  
      
    import os,time, thread  
      
      
    def isRendering(time,os) :  
      
      print(time.ctime())  
      
      while c4d.CheckIsRunning ( c4d.CHECKISRUNNING_EXTERNALRENDERING ) :  
          print("render in progress...")  
      
          time.sleep(4)  
        
      print(time.ctime())  
      print("render complete.")   
      
      
    def main() :  
      
        
      c4d.CallCommand(12099)  
        
      if c4d.CheckIsRunning ( c4d.CHECKISRUNNING_EXTERNALRENDERING ) :  
          thread.start_new(isRendering,(time,os))  
      
    if \__name\_\_=='\__main\_\_':  
      main()  
    

    Best wishes
    Martin



  • On 06/01/2015 at 21:54, xxxxxxxx wrote:

    Hi there. It is possible.

    There are a few issues you'll need to address to make this happen:
     - regex to split up the file name so you can get the multipass type ( object buffer, diffuse, etc ) I would use http://regex101.com to help you get that all figured out. From there, you can isolate the multipass name and create the directories based on those names.

    - How you're going to move/overwrite the files ( new directory or a re-render ). I would recommend shutil.copy2 for both moving and overwriting files. I had issues with shutil.move. Also, you'll want the files that you're going to move in a list and move that list only. Rinse and repeat until the render is done.

    try:
        if path.exists( existingFile ) :
            print "    Overwriting " + existingFile
            shutil.copy2( fullPath, newDir )
            os.remove( fullPath )
        else:
            print "    Moving " + f
            shutil.copy2( fullPath, newDir )
            os.remove( fullPath )
    except IOError as e:
        print "    File may have already been moved"
    except WindowsError as f:
        print "    File may have already been moved or permission denied"
    

    - I would recommend moving files every so many seconds during the render to avoid a massive pileup of transferring 10000+ files once the render is complete.

     while renderCheck == True:
            time.sleep ( 5 )
            renderCheck = c4d.CheckIsRunning ( c4d.CHECKISRUNNING_EXTERNALRENDERING )
    

    Hopefully this is enough to get you going.  :)
    Have fun!



  • On 07/01/2015 at 01:08, xxxxxxxx wrote:

    Hello Herbie,

    thanks for the lines.
    Unfortunately that was not the problem I mentioned.
    I´m allready able to rearrange the rendered pictures,
    but I was searching for a way to update the compositing file (e.g. the after effects file), in a way that
    it updates the changed filepasses of the renderpasses.
    Do you have a solution for this issue?

    Best wishes
    Martin



  • On 07/01/2015 at 01:48, xxxxxxxx wrote:

    Hi Monkeytack.
    I was talking about Compositing Project File (aec), and not the actual composition file.
    In AEC file just replace the paths and you are good.



  • On 07/01/2015 at 10:19, xxxxxxxx wrote:

    Sorry monkeytrack, I was responding to soupman99.. didn't realize the original post was months old.

    As for the AE file. If you're not updating the aec file and just want to update the passes in the AE project, you can save out an aepx file ( XML file ) from AE and replace the paths there. This will allow you to do all of the scripting in python.

    If you don't want to save out an aepx file, you can use regex to parse the current sequence and get the multipass name, then append it to it's filepath. Once that's been rebuilt, use .replaceWithSequence in AE to replace the footage. This approach will need to be done in javascript though..



  • On 07/01/2015 at 13:00, xxxxxxxx wrote:

    Hi,

    @Tomas
    Following your suggestion, I can change the file but the redered pictures could´nt be found in Ae.
    What did I miss?
    ''''EDIT
    If the compositing file is inside the renderpasses folder the code will work, great so far!! Thanks
    Do you know which part of the string I´ve to change to store the compositing file and the renderpasses in different folders?

    The File structure:
    ['CINEMA 4D COMPOSITION\r\rRESOLUTION 800 600\rFROM 0\rTO 10\rRANGE 91\rFPS 30\rFIELDS NONE\rASPECT 1.000000\rVERSION 7\r\rCOMPOSITION NRM ON "change files"\r{\r  STEREONUM -1\r  FSEQ NRM LINEAR PREMUL ON RGB NMLF NOPARENT -1 -1 "/User/blablubb/Desktop/AE_CHANGE_TEST/new_folder/change files0000.tif"\r}\r\r']

      
      doc = c4d.documents.GetActiveDocument()  
      RenderData = doc.GetActiveRenderData()  
      path_re=  RenderData[c4d.RDATA_PATH]  
      
      path=os.path.dirname(path_re)  
      dirList=os.listdir(path)  
        
      #let´s say this is the compositing file  
      fname = str(path+"/"+dirList[1])  
      
      #open file and read the stored string  
      with open(fname,'r') as f:  
          content = f.readlines()  
          f.close()  
      
      #set up the replace string  
      replace_path = "/User/blablubb/Desktop/AE_CHANGE_TEST/new_folder/change files"  
      new_str = content[0].replace( path_re, replace_path)  
      content[0]=new_str  
      
      #write the new file  
      f =  open(fname,'w')   
      f.writelines(content)  
      f.close()  
    

    Thanks in advance

    @Herbie
    again thanks,
    both ways require that I open Ae, which I don´t want, am I right?
    Anyway, could you please show an example script?
    Thanks in advance

    Best wishes
    Martin



  • On 07/01/2015 at 14:37, xxxxxxxx wrote:

    Hi Monkeytack. I am not sure I understand what you are asking.

    Let's take it from the top. Once you render from Cinema 4D image sequences, AEC Compositing Project File is placed to sake folder where Main pass goes. Here's how my AEC file looks like:

      
    CINEMA 4D COMPOSITION   
      
    RESOLUTION 800 600   
    FROM 0   
    TO 10   
    RANGE 91   
    FPS 30   
    FIELDS NONE   
    ASPECT 1.000000   
    LOCAL   
    VERSION 7   
      
    COMPOSITION NRM ON "main"   
    {   
    STEREONUM -1   
    FSEQ NRM LINEAR PREMUL ON RGB NMLF NOPARENT -1 -1 "/Users/Tomas/Desktop/render/MAIN/main0000.tif"   
    }   
      
    FSEQ <-> LINEAR PREMUL ON RGB NMLF NOPARENT -1 -1 "/Users/Tomas/Desktop/render/PASS/PASS_blend_1_0000.psd"   
      
    CAMERA "Camera"   
    {   
    SHOWFROM 0   
    SHOWTO 10   
    KEY 0 600 300 -600 45 -19.45 0 53.130102 1000 1   
    KEY 10 600 300 -600 45 -19.45 0 53.130102 1000 1   
    }   
      
    

    Now. If you rename your Main pass images or put them in another folder, just change the path

    FSEQ NRM LINEAR PREMUL ON RGB NMLF NOPARENT -1 -1 "/Users/Tomas/Desktop/render/MAIN/main0000.tif"
    

    to something else. For that use some clever RegEx or something.

    Same goes for Multi-pass sequence folder - just update the links and save the file.

    Does that help?

    EDIT
    If you change the name of you Main pass images (in my case it's main0000.tif) to something different like XXX0000.tif, then you also have to update the COMPOSITION NRM ON "main" to COMPOSITION NRM ON "XXX" in same AEC file.



  • On 08/01/2015 at 07:41, xxxxxxxx wrote:

    Hi Tomas,

    if you analyze the code i´ve posted, you might have seen that I do it the same way you´ve described it.
    Whitout using re module ok, but it should work anyway.

    I change the search path of the rendered pictures.

    But this only works, if the compositing file(aec file) is inside the same folder as the rendered pictures.
    For whatever reason.
    It should work, even if I move the aec file later on to another folder, too.

    I guess I miss something. Any idea?
    Could you please post a working example for comparison?

    Thanks in advance
    Martin



  • On 08/01/2015 at 22:59, xxxxxxxx wrote:

    What error are you getting? That files are missing when import AEC file to AE? Right?
    After Effects should load AEC file no matter where that AEC file is, as long as all paths, linking to images, exist.

    Are you sure you are updating COMPOSITION NRM ON "change files" line in AEC file to match your new name if you are renaming image sequences? change files - > NEW NAME

    Can you try updating AEC file manually and check if AE loads files OK?

    And I am sorry I cannot upload you a working example from Renomi, as there were 3rd parties involved in writing this part of the code.


Log in to reply