Changing mental ray sampling mode though Maxscript in 2014

Changing mental ray sampling mode though Maxscript in 2014

Anonymous
Not applicable
765 Views
3 Replies
Message 1 of 4

Changing mental ray sampling mode though Maxscript in 2014

Anonymous
Not applicable

Hey everyone,

 

I've been working on a custom UI to set mental ray settings and have run in to a possible bug in 2014. (If it's just me missing something though that's ok too!) 🙂

 

When trying to change the 3 sampling mode dropdownlist in the render settings, it's not letting me switch to one of them.

 

In the help it says that it depends on 2 switches that test either true or false.

 

.UnifiedEnable and .ScanlineEnable

 

Help file: mental ray maxscript parameters (Under "Samples per Pixel" and "Scanline")

 

However, when I try so set the .ScanlineEnable to true it never seems to do so.

It returns true if I do it manually int the listener, but when it test it again right after it's set to false again and thus it doesn't update the dropdownlist in the render settings.

 

If anyone could confirm this is indeed a bug or correct my workflow, any help is much appreciated.

 

mr = renderers.current

fn setUnified =
(
    mr.UnifiedEnable = true
    mr.ScanlineEnable = false
)
				
fn setClassic =
(
    mr.UnifiedEnable = false
    mr.ScanlineEnable = false
)
				
fn setScanline =
(
    mr.UnifiedEnable = false
    mr.ScanlineEnable = true
)
				
case ddl_samplemode.selection of
(
    1: setUnified()
    2: setClassic()
    3: setScanline()
    4: setClassic()
)

 M.

0 Likes
766 Views
3 Replies
Replies (3)
Message 2 of 4

Swordslayer
Advisor
Advisor

As far as I can tell, you are right, it doesn't work for me either. If you don't care about localized max versions that much, there's still the UIAccessor way, though:

 

(
	local WM_COMMAND = 0x111
	local CB_SETCURSEL = 0x014E
	local CBN_SELENDOK = 9

	local items = #(
		"Unified / Raytraced (Recommended)",
		"Classic / Raytraced",
		"Rasterizer / Scanline"
	)
	
	renderSceneDialog.open()
	tabbedDialogs.setCurrentPage #render (tabbedDialogs.getPageID #render 2)

	local hwnd = for child in (windows.getChildrenHWND 0P) where matchPattern child[5] pattern:"Render Setup: *" do exit with child[1]
	local modeData, rollupHWND = (windows.getChildHWND hwnd "Sampling Quality")[2]

	for item in items while modeData == undefined do
		modeData = windows.getChildHWND rollupHWND item

	windows.sendMessage modeData[1] CB_SETCURSEL 2 0
	windows.sendMessage modeData[2] WM_COMMAND ((bit.shift CBN_SELENDOK 16) + UIAccessor.getWindowResourceID modeData[6]) modeData[1]
	renderSceneDialog.commit()

	local mr = renderers.current
	format "Unified: %, Scanline: %\n" mr.UnifiedEnable mr.ScanlineEnable
)

 

0 Likes
Message 3 of 4

Anonymous
Not applicable

Wow, crazy workaround.

 

I'm only creating a basic script, so this might be a bit over the top, but it gave me a new perspective on how things can be accessed and changed. It'll take me a while to get my head around it, but thanks for the detailed reply! 🙂

 

M.

0 Likes
Message 4 of 4

Anonymous
Not applicable

Hi, I solved this by closing Render Setup dialog before changing the parameters and render

renderSceneDialog.close()

 

0 Likes