View Full Version : Changing filename of renderelements prerender
01-15-2009, 01:30 PM
The Maxscript help file says:
In the #preRender callback, you can't change any of the render parameters (height, width, aliasing, etc) and affect the current render sessions. Those parameters have already been set up internally in 3ds Max, and so changes to them won't occur until the next render session occurs.
I'd really like to set the filenames/paths of my renderelements at rendertime (this due to long project paths and how stuff is organized at work)
This code works, but I have to cancel the render and render again for the effects to take effect:
function setUpRenderElements =
re = maxOps.GetCurRenderElementMgr()
numb = re.numrenderelements()
for i=0 to (numb-1) do
el = re.getrenderelement i
currentFileName = (fileNameFromPath (re.GetRenderElementFileName i))
newFileName = "C:\\" + currentFileName
re.SetRenderElementFileName i newFileName
callbacks.addScript #preRender "setUpRenderElements()" id:#renderPaths
So I guess I either need a way to cancel the current render and restart it (i cannot find a way to cancel a render using maxscript), or I need to make use of some other callback.
-- As an alternative I figured I'd just make a small render script fixing the paths and then executing render()
01-16-2009, 12:16 PM
I'm not exactly sure what you're trying to achieve but maybe this will help.
When you create a render element, if you leave the filename field blank then it is tied to the render output file, so any changes to the render output filename will be reflected in the render element output filename. If you change the render element output, this link is lost.
So, theoretically if you let max handle the element output filename all you need to do is to change the name of the render output filename and the rest sohuld happen automatically.
01-16-2009, 01:09 PM
As for cancelling a render - no, there isn't any direct code that you could call. You can, however, detect the render progress dialog popping up and press the Cancel button by code;
fn checkDialog = (
local hwnd = dialogMonitorOps.getWindowHandle()
if (uiAccessor.getWindowText hwnd == "Rendering") then (
if (querybox "Cancel?") then ( uiAccessor.pressButtonByName hwnd "Cancel" )
-- these go just before the render begins.
-- You may place them in e.g. a #preRender callback,
-- or before your own 'max quick render' or render() call.
dialogMonitorOps.enabled = true
dialogMonitorOps.interactive = false
dialogMonitorOps.registerNotification checkDialog id:#test
-- max quick render
-- this one goes after the render has finished
-- you may place it in e.g. a #postRender callback,
-- or after your own 'max quick render' or render() call.
dialogMonitorOps.enabled = false
01-16-2009, 01:09 PM
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.