Notifications
Clear all

[Closed] post-render script after baking

Hi.

well most is said in the title. Is there a way to run a script after a render to texture? The standard post-render-script doesn’t work there.

I am using Max9.

thanks, David

11 Replies

use the standard callbacks, rather than the render scene dialog scripts;


callbacks.addScript #preRender "format \"#prerender
\"; print (callbacks.notificationparam())" id:#test
 callbacks.addScript #preRenderEval "format \"#preRenderEval
\"" id:#test
 callbacks.addScript #preRenderFrame "format \"#preRenderFrame
\"" id:#test
 callbacks.addScript #beginRenderingActualFrame  "format \"#beginRenderingActualFrame  
\"" id:#test
 callbacks.addScript #postRenderFrame"format \"#postRenderFrame
\"" id:#test
  callbacks.addScript #postRender"format \"#postRender
\"" id:#test
  

You can detect whether it’s RTT by checking element 1 of #preRender’s notification params… it will be #bakeSelected.

wow. this looks really helpful. I still have to figure out exactly how callbacks work, and what your code does, but this is definitely pointing me in the right direction. thanks.

That snippet basically just sets up some callback handlers that print out the callback name. I’ve been using something similar with prettymuch all the callbacks whenever I think “I wonder if that triggers a callback…”.

Figured I’d finally pack that up proper;
http://www.scriptspot.com/3ds-max/cblogger-callbacks-logger

As far as callbacks go… they’re basically built-in functions that 3ds Max calls whenever a certain event occurs. E.g. when a render ends, it calls the #postRender callback. You could use that to then grab the last rendered image and save that to a file – a la the RenderHistory script(s)

Hum…although i am registered at scriptspot I always get a access denied screen when clicking on your link.

Callbacks are truly a great way of adding features to 3dsmax (though i find it disturbing to script inside a string).

Unfortunately the render to texture dialog is not properly documented. I would like to have access to all the settings inside the dialog, especially the pathnames.

David

2 Replies
(@zeboxx2)
Joined: 2 years ago

Posts: 0

Ah – I only just submitted them… they may have to go through a review process that isn’t quite explained on the pages… sorry about that. I suspect it’ll become available shortly, but for now I’ll attach it to this thread as well.

So don’t

Put all the code you need inside a function, and then simply call that function in the callback. E.g.


fn helloWorld = ( print "hello world" )
callbacks.addScript #preRender "helloWorld()" id:#test
-- callbacks.removescripts id:#test

Makes things much, much easier.

I think that the path names are actually stored in the objects;

showinterface $.inodebakeproperties

But if you do need access to that dialog specifically, you’d have to work with the UIAccessor bits.

(@magicm)
Joined: 2 years ago

Posts: 0

One thing to note here though, is that if you decide to make your callbacks persistent (ie, saved with the scene), you’ll need to make sure that the callback function (helloWorld in this case) is available when you close/start max and open the scene again.

Martijn

might help if I didn’t forget to attach… let’s try again

Oh, wow, the callback logger is a useful tool. thanks. Amazing how many callbacks get sent after hitting render.

I think that the path names are actually stored in the objects;

ah ok. That's pretty comfortable.

Put all the code you need inside a function, and then simply call that function in the callback. E.g.

Hehe. that sure makes life easier

But if you do need access to that dialog specifically, you'd have to work with the UIAccessor bits.

I searched the manual about this UIAccessor thing, and it looked pretty confusing. Any idea how to use it to get the render to texture path?

1 Reply
(@zeboxx2)
Joined: 2 years ago

Posts: 0

Yep

Try with these functions:


 -- <undefined|string>getRTTOutputPath()
 --   gets the output path from the RTT dialog
 --   Returns:
 --	 undefined - output path dialog element not found
 --	 string - the output path set in the RTT dialog
 --   Notes:
  --	 The RTT dialog must be open
 --   Example:
 --	 myPath = getRTTOutputPath()
   fn getRTTOutputPath = (
 	local hwndchildren = windows.getChildrenHwnd (windows.getDesktopHWND())
 	local rttDialogFound = false
 	local outputPath = undefined
 	for child in hwndchildren do (
 		if (findString child[5] "Render To Texture" != undefined) do ( rttDialogFound = true )
 		if (rttDialogFound) then (
 			if (child[5] == "Path: ") then (
 				outputPath = UIAccessor.getWindowText (UIAccessor.getNextWindow child[1])
 			)
 		)
 	)
 	outputPath
 )
 
 
 -- <false|OK>setRTTOutputPath <string>path
  --   sets the output path in the RTT dialog to the given path
 --   Parameters:
 --	 path - the path to set.  String.
  --   Returns:
  --	 false - output path dialog element not found
  --	 OK - the output path was set in the RTT dialog
 --   Notes:
 --	 The RTT dialog must be open
  --   Example:
  --	 result = setRTTOutputPath myPath
    fn setRTTOutputPath path = (
 	local hwndchildren = windows.getChildrenHwnd (windows.getDesktopHWND())
 	local rttDialogFound = false
 	local result = false
 	for child in hwndchildren do (
 		if (findString child[5] "Render To Texture" != undefined) do ( rttDialogFound = true )
 		if (rttDialogFound) then (
 			if (child[5] == "Path: ") then (
 				UIAccessor.setWindowText (UIAccessor.getNextWindow child[1]) path
 				result = OK
 			)
 		)
 	)
 	result
 )
 

Hi Zeboxx2. I am really sorry that it took me so long to reply to your last post. I hate these people who ask questions, get answers, and then never reply again. That is no decent behavior on a bulletin board. To my excuse, I have been on holiday with only little time for internet and and no computer with 3dsmax.

Your script does what it promises, which is great. thanks for taking the time to write those handy functions. I still have to figure how some of the commands work, but i understand the general flow. These scripts combined with a callback system and the $.INodeBakeProperties, are a perfect basis for my own script.

I had not expected that getting information from the rtt dialog would be so troublesome. But that’s ok, because i learned a lot of cool new stuff.

thanks again, David

No prob – glad it worked out for you, and I hope you had a good holiday