Enabling and disabling Global rendering in slate editor?

Enabling and disabling Global rendering in slate editor?

Lewis_mxr
Participant Participant
3,914 Views
12 Replies
Message 1 of 13

Enabling and disabling Global rendering in slate editor?

Lewis_mxr
Participant
Participant

Anyone know what to call to disable and enable the 'Global rendering' feature in the slate editor?

 

Looked everywhere in maxscript help.. and nothing plus the macrorecorder is blank.

 

Thanks in advance.

0 Likes
Accepted solutions (1)
3,915 Views
12 Replies
Replies (12)
Message 2 of 13

denisT.MaxDoctor
Advisor
Advisor
actionMan.executeAction 369891408 "55572"

"Enable Global Rendering"... it toggles "global rendering".  You have to activate the Slate Editor window and run the action. 

0 Likes
Message 3 of 13

Lewis_mxr
Participant
Participant

Thanks @denisT.MaxDoctor 

 

I did try this already but doesnt seem to work on 2023.3

 

When you say activate, i assume theres nothing more than just having the slate editor open? i.e. sme.open()

or am I missing something?

 

eitherway its not toggling the state.

 

Cheers

 

0 Likes
Message 4 of 13

denisT.MaxDoctor
Advisor
Advisor

@Lewis_mxr wrote:

Thanks @denisT.MaxDoctor 

 

I did try this already but doesnt seem to work on 2023.3

 

When you say activate, i assume theres nothing more than just having the slate editor open? i.e. sme.open()

or am I missing something?

 


the window has to have a focus at the moment of action execution:

(
	sme.open() 
	sme_hwnd = windows.getchildhwnd 0 "Slate Material Editor"
	setfocus sme_hwnd[1] 
	actionMan.executeAction 369891408 "55572"
)
Message 5 of 13

Serejah
Advocate
Advocate
(SME.GetMainframe()).SetFocus() before calling executeAction should be enough
Message 6 of 13

Lewis_mxr
Participant
Participant

Great thanks! @denisT.MaxDoctor @Serejah  I just realised I found your guys thread on cg society 🙂 , and looks like we are trying to do the same thing and have same issues (@Serejah) my next task was to see if i can get its current state, but the ischecked always returns false even when its active in sme.

 

@Serejah Did you ever find out a solution to checking its state? looks like you wanted same thing for 'Hide unused node' whereas im after the 'Global rendering' button.

 

Many thanks to you both!

0 Likes
Message 7 of 13

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

follow the lines and see how all works:

sme.open() 

sme_hwnd = windows.getchildhwnd 0 "Slate Material Editor"
sme_rend_tb = windows.getchildhwnd sme_hwnd[1] "toolbar_rendering"
_ = UIAccessor.GetFirstChildWindow sme_rend_tb[1]
rend_bt = UIAccessor.GetNextWindow _

g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
cb = g.GetICustButton rend_bt
cb.IsChecked

cb.SetCheck on
cb.SetCheck off

g.ReleaseICustButton cb

 

I'm not a fan of the dotnet max api interface, but if no SDK is available, this is your only option...

 

0 Likes
Message 8 of 13

Lewis_mxr
Participant
Participant

Perfect, thanks @denisT.MaxDoctor works great!

 

I dont think I had any chance of working this one out.

 

Much appreciated!

0 Likes
Message 9 of 13

Lewis_mxr
Participant
Participant

Thought i would follow up to this,

 

Bearing in mind im a 3d artist moonlighting as a coder/programmer, I found this pretty robust when testing it. Just using your dotnet code to do the check and actionMan. to execute it. The setcheck seem to uncheck UI but the function was still active in background when testing if sme was open or closed. I know it shouldnt matter too much if closed but the ui was flickering whilst global rendering updated, so just thought its best to kill it regardless. none the less couldnt of solved it without your help. Thanks again

 

		(	
			sme_hwnd = windows.getchildhwnd 0 "Slate Material Editor"
			sme_rend_tb = windows.getchildhwnd sme_hwnd[1] "toolbar_rendering"
			_ = UIAccessor.GetFirstChildWindow sme_rend_tb[1]
			rend_bt = UIAccessor.GetNextWindow _

			g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
			cb = g.GetICustButton rend_bt
			cb.IsChecked

			if sme.IsOpen() then (
			   -- print "sme open"
				if cb.IsChecked == true do
				(
					print "sme open on"
					(SME.GetMainframe()).SetFocus() 
					actionMan.executeAction 369891408 "55572"
				)
			)
			else
			(
				--print "sme not open"
			
				if cb.IsChecked == true do 
				(
					print "sme not open on"
					(SME.GetMainframe()).SetFocus() 
					actionMan.executeAction 369891408 "55572"
				)
			)
		)

 

0 Likes
Message 10 of 13

Serejah
Advocate
Advocate
sme_hwnd = windows.getchildhwnd 0 "Slate Material Editor"

if you have multiple max instances running you might end up with the wrong sme window without even knowing that

this is the correct & localization independent way to get the handle

fn GetSMEHandle =
(
	local max_hwnd = windows.getMAXHWND()
	sme_hwnd = for m in windows.getChildrenHWND 0 where m[4] == "NodeJoeMainWindow" and m[6] == max_hwnd do exit with m[1]
)

 

Message 11 of 13

Lewis_mxr
Participant
Participant

Thanks for this @Serejah I have updated it, good catch, i know a few people who will have more than one instance running so appreciate it!

0 Likes
Message 12 of 13

denisT.MaxDoctor
Advisor
Advisor

@Lewis_mxr wrote:

I know it shouldnt matter too much if closed but the ui was flickering whilst global rendering updated, so just thought its best to kill it regardless.


I don't really understand the use of this script... by fact it only works if the slate material editor is open. Wouldn't it be easier to just click this button or call an assigned shortcut (hotkey)?

0 Likes
Message 13 of 13

Lewis_mxr
Participant
Participant

This is part of a larger script where it makes alot of changes to multiple materials all at the same time, if this is on there is alot of processing in the background vs it being off. IMHO it always seemed like a bad feature in the slate editor anyway, when it was first introduced i was abit confused as to why you would want to visualise this update or having the ability to toggle it on and off, then realised it was due to the overhead of updating them all.. i remember having substanial lag when it updated alot of nodes all at same time and its rather annoying. This was just a precautionary thing having it off whilst my script makes multiple edits to multiple materials, i have spinners set to on change so every increment triggered a update to global renderer..

 

0 Likes