[Closed] Determine Origin of Render [SDK or MXS]
Here’s one that’s been twisting my brain lately. :banghead:
How is it possible to tell from any of the render callbacks (whichever), whether or not the current render was started from the UI, or launched via the Render() MAXScript command?
Also, though I know this one is probably a fantasy, is it possible to return from any of the callbacks the Bitmap the Renderer is rendering to (the *tobm value passed to the renderer in Renderer::Render)?
Keep in mind this is not the same as GetLastRenderedImage()
i think it’s just not possible. they both use the same SDK call but with different arguments. the UI version calls it with the setup configuration. script calls it with the default settings.
the same call is it… i don’t see any way to get a difference.
I found a solution for the first question, but the solution is disgusting: check if the render progress dialog is visible or not. :shrug:
Oh god… I feel dirty even posting this ‘solution’ to your first problem
Basically, the render() command fires preRender before preImageViewerDisplay, clicking on the render button does it the other way round. The only catch is that if the frame buffer is already open, preImageViewerDisplay will not be fired, hence the check. …this is just horrible haha.
I guess this will completely fail if the frame buffer is set to not show during render, but maybe it will give someone a better idea.
callbacks.removeScripts #PreRender
callbacks.removeScripts #preImageViewerDisplay
callbacks.removeScripts #PostRender
global renderType = undefined
global imageViewCalled = false
function preRender = (
if renderType == undefined do renderType = #scripted
)
function preImageViewerDisplay = (
if renderType == undefined do renderType = #clicked
imageViewCalled = true
)
function postRender = (
if imageViewCalled == false do renderType = #clicked
print renderType
rendertype = undefined
imageViewCalled = false
)
callbacks.addScript #PreRender "preRender()"
callbacks.addScript #preImageViewerDisplay "preImageViewerDisplay()"
callbacks.addScript #PostRender "postRender()"
It is the same as UI rendering, also max quick render.
Wow, cool idea, I didn’t know about the different order. Unfortunately as you mentioned it will fail in both cases where the VFB is already open or not set to open
I don’t know, it seems the solution I am using, while ugly, seems to be working so far. I just check for the existence of a #32770 dialog, with 2 progress bars, 2 buttons and 1 rollout.