Notifications
Clear all

[Closed] Incremental Render Tool

Hey guys,

I’ve been playing around with Maxscripting a little bit and I came up with this simple tool to save incrementally named renders (office_001, office_002) with the click of a button.

As I say I’m very new to the world of programming and maxscripting, but I’m totally addicted. I’m fully aware there are gaping wounds and issues with the script, but as a 1 day project it was a bit of fun, and it’s all helping me get to grip with proper syntax and commenting.

I would advise against ever using it in a production environment as I haven’t really tested it properly, but if people could have a look I’d be very interested in hearing some comments/critiques on my technique and syntax.

Cheers guys,


-- Incremental Render Toolbar v1.0 by Gary Boyle
-- A very simple script to create a dockable toolbar that allows a 1 button solution to incremental render saving
-- Select a directory using the 'S' button, every time you press the 'R' button a new jpg copy of your render will be saved in this location.
-- Please note that I am just beginning to learn Maxscripting and this script may not be the best solution to incremental saving. There are issues with the current script (it will only save as a jpg)
-- and I haven't done extensive testing of the script. Basically I'm just releasing it so that I can get some feedback on my scripting and hopefully it may help someone out there.
-- Please please don't use it on any important projects, as I say it is basically untested and I would hate to see anyone lose work because of my novice scripting!
-- Hopefully I will be able to update this script in the future.
-- If you have any comments or feedback, please feel free to get in touch at Gary_boyle@hotmail.co.uk.
-- Cheers!
-- v.1
 
-- Known issues:
-- Currently only set to add a .jpg suffix to saved renders. Will probably crash if any other filetype is used.
-- May have issues if render number goes above 100.
-- Does not render with Vray VFB (due to vfb:true in render command). If vfb:false then it does use the Vray VFB but window dissapears after render.
-- Issues with Gamma and LUT if using LWF (probably related to Vray VFB issues).
 
 
macroscript Increment
category:"Pongetools"
buttonText:"+1"
toolTip:"Incremental Render"
(
GLOBAL Incfloatobject
rollout Incfloatobject "Increment" 
(
GLOBAL CurrentRenderNumber = 001 as integer 	-- Base render number
LOCAL CurrentRenderLocation = rendOutputFilename -- Current render location under Render Output dialog (if applicable)
 
button Renderplus "R" across:3 pos:[10,8]
button setlocation "S" across:3 pos:[40,8]
editText renderlocation text:CurrentRenderLocation width:450 height:21 readonly:true across:3 pos:[70,8]
on Renderplus pressed do
(
	loctemp = rendOutputFilename as string -- Save render location as a string
	count = loctemp .count - 4	 -- Count the length of location string and delete file extension
	CurrentRenderNumber +=1	 -- Increment the base number
	StrCurrent = CurrentRenderNumber as string + ".jpg" -- Add base number to file location and add .jpg
	newnumber=replace loctemp count 5 StrCurrent -- Replace end of location string with new base number
	renderlocation.text = ""			-- Clear edittext box
	(renderlocation.text) = append(renderlocation.text) (newnumber) -- Put new location into edittext box
	render outputfile:renderlocation.text vfb:true quiet:false progressbar:true -- Render image with current settings to output location
)
 
on setlocation pressed do
(
newlocation = getSaveFileName caption:"Select a Save Location" \ 	-- Open a new save file dialog (jpg and tga only, although this can be expanded)
	 types:"Jpeg(*.jpg)|*.jpg|Targa(*.tga)|*.tga|All|*.*|"
renderlocation.text = ""				 -- Clear edittext box
(renderlocation.text) = append(renderlocation.text) (newlocation)	-- Update edittext box
CurrentRenderNumber = 001 as integer			 -- Reset base render number
rendOutputFilename = renderlocation.text			-- Update output filename variable
renderSceneDialog.update()				 -- Close and reopen render scene dialog (if dialog is open, changes won't be immediatly apparent)
)
)
createDialog Incfloatobject 550 35		-- Create new dialog (width and height numbers apply to my workspace, may need to be changed)
cui.RegisterDialogBar Incfloatobject		-- Register dialog as dockable
cui.DockDialogBar Incfloatobject #cui_dock_top -- Dock to the top
 
) 
 

1 Reply

Nice work… only one issue I see ( way minor ) is a global var for no reason… You want to avoid using global vars, I dont see a reason for CurrentRenderNumber to be global… if you do want to access it from a global scope you can get there like this when the dialog is active.

Incfloatobject.CurrentRenderNumber

Keep on MaxScript’n