Maxscript to disable/enable "Get Resolution from Max"

Is there a way to enable/disable Get Resolution from Max with Maxscript? I’m trying to create a pre-render and post-render script that takes the resolution from Max, puts in the width and height from Vray and then takes the simplest form of the resolution and puts that in the resolution of Max. Then after the render puts everything back to its original state. The only thing I can’t seem to find is the code for enabling or disabling get resolution from max.

As to why I’m trying this: 3ds max frame buffer size vs v-ray frame buffer size - V-Ray for 3ds Max :: General - Chaos Forum

The property is called
“output_getsetsfrommax”

Thanks Lele, is there a list somewhere or documentation, because I couldn’t find it in the chaos docs.

I found the vr properties command but maybe there’s some more documentation on all the properties?

EDIT:

I just tried vr.output_getsetsfrommax, it returns as false, whether it’s turned on or not. If I do vr.output_getsetsfrommax = true or false it doesn’t seem to change in the UI.

I’m just learning to script so forgive me if I’m asking stupid questions.

The only way to figure them out is via the show() command, f.e.
show renderers.current

I just tried vr.output_getsetsfrommax, it returns as false, whether it’s turned on or not. If I do vr.output_getsetsfrommax = true or false it doesn’t seem to change in the UI.
Eheh, you need to call “renderSceneDialog.commit()” to see the changes.
Help

Thanks.

When I try this:

vr.output_getsetsfrommax = true
renderSceneDialog.commit()

The Render Settings windows flashes but there are no changes, neither true nor false changes the UI.​

I even tried renderSceneDialog.update()

It works fine for me, even without committing…

3dsmax_OE8DKegK5a.gif

Indeed it works with renderers.current. but not with vr.

Almost there, so far I have this:

-- Store the original values
originalWidth = renderWidth
originalHeight = renderHeight

-- Set VRay width and height
renderers.current.output_width = originalWidth
renderers.current.output_height = originalHeight

-- Calculate the simplest form of the original output size
fn simplifyFraction num den = (
    common = gcd num den
    #(num/common, den/common)
)

simplifiedValues = simplifyFraction originalWidth originalHeight

-- Set new resolution in 3ds Max
renderWidth = simplifiedValues[1]
renderHeight = simplifiedValues[2]

--Disable get resolution from Max
renderers.current.output_getsetsfrommax = false​

But there must be something wrong with my logic, because it worked once, and then it stopped working properly, it started to set the simplest form values in the vray output settings not in 3ds Max.

I’ve got it working, although I’m not sure if what I’m doing is correct in terms of coding, but adding renderscenedialog.close() in the beginning works.

Now to create a post render script that puts everything back in its place.

So it only works when using it manually, when set as a pre-render script, it doesn’t seem to be doing anything. Am I missing something?

Anyone with better scripting capabilities that knows what I’m doing wrong? I’ve already posted on the maxscript FB group but no response either :frowning:

Try turning off the maxscript safety bits.
If that fails, try and set the scope to a local one (add a pair of brackets enclosing the script.), so you’ll know which variable has or has not been initialised right at the beginning of the script.
If that fails as well, kindly send me the latest copy of the script and i’ll take a look.

Awesome I got it to work!!! Thank you Lele, appreciate it. :slight_smile:

And you’re not telling us how? How cruel! :smile:

Haha, that’s the thing about scripting, especially when you don’t know half of what you’re doing, but I had some help of ChatGPT to rewrite some things and now it seems to work. I think something went wrong initially with calculating the greatest common divisor, although it worked at some point until it didn’t.

Granted I’m not sure if it’s the most optimal way of doing this,…probably not.

In any case if anyone might benefit from having these scripts, they are attached. Just put them in the Pre and Post render scripts in the Render Setup window. Not sure how much RAM this might save on bigger resolutions with multiple render elements, but every bit counts I guess :smile:.
DT_PrePostRenderVFBResolution.zip (904 Bytes)