Automated file naming (variable)

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 12 December 2012   #1
Question Automated file naming (variable)

Hi guys!

I'm wondering, whether there's an easy way to give every new render a new filename without having to change the name in the render options over and over again. Is there a way to put variables in your filename, e.g. "render_XY_$time.tif" ($time being the variable)?

cheers,
Julian
 
Old 12 December 2012   #2
well the time (frame) subfix is the c4d default. every render is called myName_000(0),
where the zeros stand for the frame number (as soon as you set the render range to
something diffrent than current frame).

however, for more sophisticated string fromats you have either to write a script or to
use xpresso. to get hold of the documents settings container within xpresso, press
ctrl + d and drag the little file icon on top of the attribute manager into your xpresso
graph. to get hold of the render settings simply drag the render settings node name
from the render settings (ctrl + r) window into your xpresso graph. with these
components you can encode any information hold within the scene into the filename,
like timecode, rendersettings, camera and so on.

Last edited by littledevil : 12 December 2012 at 09:58 PM.
 
Old 12 December 2012   #3
We spend a lot if time and attention renaming render files. Therefore an integrated naming system would be handy.

For still images we use the frame numbering incrementally to distinguish the renderings. At each work step we shiFt one frame.

This has been mentioned a lot of times but I wish there would be an option to name the save file path "relatively" to the c4d file. Instead of /Volume/Users/Me/Documents/Projects/Project99/Render/Render_final_
you could write
/Render/Render_final_
(OSX), creating the inclosing folder ("Render") if not there yet, next to the model file same thing for the texture path.

Last edited by klueck : 12 December 2012 at 12:58 PM.
 
Old 12 December 2012   #4
Each house needs its specific workflow so it's pretty
hard to set up a generic solution.
Python does give pretty much options "for free".

For inspiration, attached is a Save path system
based on a Project Folder with automatic subfolders
for Document name (Scene), active Camera name, image name
as well as a Multipass folder (based on the same criteria).

For use in the ScriptManager.

(As usual, watch out for any formatting errors by the forum text engine)

Cheers
Lennart


# RenderPath from Active Camera example.tcastudios.com  2012
#
# Paste all into the ScriptManager.
#
# Start with an empty Save path.
# Run the script and select a image Name and Project Folder.
# Each time you run the script the Save path will be set
# to this Project folder and use/create subfolders based on:
# Document Name and Active Camera Name
# where the current render will be rendered into,
# incl. a Multipass folder if Multipass is activated.
#
# Saving the Scene with a new name will make a new
# subfolder structure in your Project folder
# named after the New scene name, again adding subfolders
# based on Active Camera.
#
# To create a new Project folder, empty the Save path in render settings
# and run the script.

import c4d
from c4d import gui, storage as s
import os, errno

DEFAULT_NAME = 'Image Name 01'

def mkdirs(newdir, mode=0777):
    try: os.makedirs(newdir, mode)
    except OSError, err:
        # Reraise the error unless it's about an already existing directory 
        if err.errno != errno.EEXIST or not os.path.isdir(newdir): 
            raise

def main():
    c4d.CallCommand(13957) # Clear Console

    adraw         = doc.GetActiveBaseDraw()
    camname       = adraw.GetSceneCamera(doc).GetName()
    if camname == 'Camera':
        camname =  'Ed_Camera'

    docname       = doc.GetDocumentName()
    docname,ext   = os.path.splitext(docname)

    current_path                = doc.GetActiveRenderData()[c4d.RDATA_PATH]
    c_cam,   current_image      = os.path.split(current_path)
    c_scene, current_cam        = os.path.split(c_cam)
    c_proj,  current_scene      = os.path.split(c_scene)
    c_path,  current_project    = os.path.split(c_proj)

    mpass = doc.GetActiveRenderData()[c4d.RDATA_MULTIPASS_SAVEIMAGE]


    print '_CURRENT SETTINGS___________'
    print '[Filepath] %s' %(current_path)
    if mpass:
        print '[MP_path] %s' %(doc.GetActiveRenderData()[c4d.RDATA_MULTIPASS_FILENAME])
    print '[Project ] %s' %(current_project)
    print '[Scene   ] %s' %(current_scene)
    print '[Camera] %s' %(current_cam)
    print '[Image   ] %s' %(current_image)

    try:    projd = c_proj
    except: projd = c4d.DOCUMENT_FILEPATH

    folder = c_proj
    if not current_path:
        # Initially set up a project Save path based on document(Scene), Active camera name
        print 'Need to set a New Project Save path'
        folder = s.LoadDialog(c4d.FILESELECTTYPE_ANYTHING,'Select Project Folder',c4d.FILESELECT_DIRECTORY,'',projd)
        if not folder: return 

    prename = current_image if current_image else DEFAULT_NAME
    saveas = c4d.gui.RenameDialog(prename) # Set/Update Image name
    if not saveas:
        return True

    # Set up the Save path based on Project, document(Scene), Active camera names and Image name
    if not current_path or current_scene != docname or current_cam != camname or current_image != saveas:
        print 'Setting a New Save path'

        dpath = os.path.join(folder,docname,camname)
        mkdirs(dpath, mode=0777)
        newpath = os.path.join(dpath,saveas)
        doc.GetActiveRenderData()[c4d.RDATA_PATH] = newpath
        
        # If MultiPass Save is On
        if mpass: 
            new_mp_path = os.path.join(os.path.split(newpath)[0],saveas+'_mp')
            mkdirs(new_mp_path, mode=0777)
            multipass = os.path.join(new_mp_path,saveas)
            doc.GetActiveRenderData()[c4d.RDATA_MULTIPASS_FILENAME] = multipass
            
        print ' '
        print '_NEW SETTINGS_______'
        print '[Filepath] %s' %(newpath)
        if mpass:
            print '[MP_path] %s' %(multipass)
        print '[Project ] %s' %(current_project)
        print '[Scene   ] %s' %(docname)
        print '[Camera] %s' %(camname)
        print '[Image   ] %s' %(saveas)
        c4d.EventAdd()
        # Optionally do the render from within the script
	#(Only if new image name/save path is set)
        #c4d.CallCommand(12099) # Render
        return True
    
    return True


if __name__=='__main__':
    main()
__________________
MSA | OSX | xfiles ...Cinema4D Tools

Last edited by tcastudios : 12 December 2012 at 11:28 AM.
 
Old 12 December 2012   #5
Would love to see this implemented too, i always render in the viewport and take a screenshot and paste it into photoshop just too avoid changing the filename every 15min.
Would it be possible to render and open automatically in photoshop in one action?
__________________
www.rizon.be
 
Old 12 December 2012   #6
In render effect settings you have the "Remote" option
for this.

Specify your PS there and try.

Cheers
Lennart
__________________
MSA | OSX | xfiles ...Cinema4D Tools
 
Old 12 December 2012   #7
Originally Posted by tcastudios: In render effect settings you have the "Remote" option
for this.

Specify your PS there and try.

Cheers
Lennart


No way! just tested this... awesome!! Thanks Lennart.
__________________
www.rizon.be
 
Old 12 December 2012   #8
Use the render queue (even for single renders) This will automatically append the camera name and a number to each render.
__________________
Matthew O'Neill
www.3dfluff.com
 
Old 12 December 2012   #9
Originally Posted by tcastudios: For inspiration, attached is a Save path system
based on a Project Folder with automatic subfolders
for Document name (Scene), active Camera name, image name
as well as a Multipass folder (based on the same criteria).


Hi Lennart
I am very interested in your code but I have no idea about scripting...
I tried to copy the code you provided into a Phyton Generator and got a terrible c4d crash (OSX).
Can't open the file anymore without crashing. No big deal, though. Could you post a complete c4d file? Or is it WIN only?

klueck
 
Old 12 December 2012   #10
Originally Posted by imashination: Use the render queue

Nice.
(the file path in the Save menu must remain empty)

This shows that an automatic image naming is a needed feature in c4d!
 
Old 12 December 2012   #11
Originally Posted by klueck: Hi Lennart
I am very interested in your code but I have no idea about scripting...

klueck


It's to be used in the ScriptManager.

Cheers
Lennart
__________________
MSA | OSX | xfiles ...Cinema4D Tools
 
Old 12 December 2012   #12
Thumbs up

Thank you very much Lennart! This python code is really impressive!
(How does one get involved in scripting and 3D as you do?)

Is there a way to write a relativ file path ??
instead of
/Volume/Users/....../Folder1/ProjectX/Var1/Renderings
just
/Renderings
?

It seems to me that you Lennart must know the solution ;-)
When using images from the Content Browser you can see a kind of relative path:
e.g. :
preset://prime.lib4d/Materials/HDRI/tex/HDR006.hdr
 
Old 12 December 2012   #13
No, the Save Path doesn't accept Relative paths I'm afraid.
But behind any Relative Path is an Absolute Path and that's
what the script example helps with. Once run it sets up
a project path and all you have to do is type the image name.
Just as if you would type a relative path.

Just put a shortcut and/or button for it.

The Content Browser paths (://preset.lib4d) are specific
to the CB and doesn't apply elsewhere in Cinema.

Cheers
Lennart
__________________
MSA | OSX | xfiles ...Cinema4D Tools
 
Old 12 December 2012   #14
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:28 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.