ScriptSpot

Forum topic · General Scripting

Press Select All in SME.

By 3dwannab · 2018-02-08

Description

In the SME menu, is there a way to press.

Select>Select All

 

Using:

actionMan.executeAction 369891408 "40063" /* SME: Select All */

 

is not really what Im after as it requires the SME to be open.

Basically the fn I want overall is to, select the nodes and then hide unused nodes.

Thanks.

Comments (19)

.

3dwannab · 2018-02-25

Thank you for your help.

Thanks & one more thing.

3dwannab · 2018-02-25

I was unchecking General and leaving everything else. It's quite simple really, thanks.

One more thing. In your posts above you wrote.

windows.sendMessage SMEhwnd 0x111 40048 0 -- hide unused nodeslots

Whereas it can also be.

windows.sendMessage SMEhwnd 0x111 41008 0 -- hide unused nodeslots

Where did you get the

40048

handler?

.

jahman · 2018-02-25

I think it's from the above dropdown menus (edit, view, select, etc), can't remember exactly.

.

jahman · 2018-02-25

forum makes messages width lower and lower so I post it here
Open gif in new tab to view it in full resolution

.

3dwannab · 2018-02-24

This seems to work much better by disabling the apply changes. BTW, what is apply changes?

Before I post the code, how do you get those vals from spy++. I've tried but can't seem to find the same values you have.

Which window do you open after I open Spy++? Windows, processes or threads?

fn getSlateHWND =
	(
		for m in (windows.getChildrenHWND 0) where m[4] == "NodeJoeMainWindow" and m[5] == "Slate Material Editor" do return m[1]
	)
 
SMEhwnd = getSlateHWND()
windows.sendMessage SMEhwnd 0x111 40023 0 -- select ALL
 
-- windows.sendMessage SMEhwnd 0xC752 0 0 -- apply changes
windows.sendMessage SMEhwnd 0x111 40048 0 -- hide unused nodeslots
-- windows.sendMessage SMEhwnd 0xC752 0 0
 
windows.sendMessage SMEhwnd 0x111 41004 0 -- press Layout All
windows.sendMessage SMEhwnd 0x111 40024 0 -- select NONE

.

jahman · 2018-02-24

You need to press Log icon in Spy++ and then in Message Options window drag target icon on to SME window. In additional window I chose child windows only.
And the last one.. there will be lots and lots of messages, hundreds. You can right-click any message that you don't need to log (timer, mousemove, cursormove etc) and press Stop Logging Message.

"Decoded message parameters" is checked (in Output settings)

Headache

3dwannab · 2018-02-24

That thing would make you go cross-eyed..

I'm not getting the same codes as you. I'm getting 00031720 for the

hide unused nodeslots

.

Also what is

0x111

. When I click I get a

WM_LBUTTONDOWN

msg. Here (https://msdn.microsoft.com/en-us/library/windows/desktop/ms645607%28v=vs…) it has

0x0201

the code.

I've "Decoded message parameters" is checked (in Output settings)

headache for sure

jahman · 2018-02-25

0x111 is WM_COMMAND
here's the list

Thanks.

3dwannab · 2018-02-24

Still not working.

Can you tell me. Do them codes work for all versions of max or do they need to be changed for each version?

Tried:

sme_av = sme.activeView
nodeViewImp = sme.GetView sme_av

/* LAYOUT VIEW START */
SMEwin = (windows.getChildHWND 0 "Slate Material Editor")[1] -- Get the HWND of the Slate Material Editor
SMElayout = (windows.getChildrenHWND SMEwin)[19][1] -- Get the HWND of the current Layout All button, 16th item in the SMEWin children array

/* SelectAll() Doesn't work */
nodeViewImp.SetFocus()
nodeViewImp.SelectAll()

windows.sendMessage SMEwin 0x111 40048 0 -- toggle Hide Unused Nodeslots
windows.sendMessage SMEwin 0xC752 0 0 -- apply changes??
UIAccessor.PressButton SMElayout

nodeViewImp.SetFocus()
nodeViewImp.SelectNone()

/* LAYOUT VIEW END */

But individually evaluating each line works. Just not together. It will work though if I select the nodes myself with CTRL+A and then run the code.

.

jahman · 2018-02-24

It works fine in 2014, but I didn't test in any other version. I doubt that codes are differ from version to version.

ps. I just run it again and it actually fails some times and looks like it has something to do with the position of cursor (mostly if it's over SME window). Hope it helps


fn getSlateHWND = (
	
	for m in (windows.getChildrenHWND 0) where m[4] == "NodeJoeMainWindow" and m[5] == "Slate Material Editor" do return m[1]
	
)

SMEhwnd = getSlateHWND()
windows.sendMessage SMEhwnd 0x111 40023 0 -- select ALL

windows.sendMessage SMEhwnd 0xC752 0 0 -- apply changes
windows.sendMessage SMEhwnd 0x111 40048 0 -- hide unused nodeslots
windows.sendMessage SMEhwnd 0xC752 0 0

windows.sendMessage SMEhwnd 0x111 41004 0 -- press Layout All
windows.sendMessage SMEhwnd 0x111 40024 0 -- select NONE

3dwannab · 2018-02-24

I've noticed an error with this code. Well not an error but it doesn't press the hide unused slots. I think the issue is with the

nodeViewImp.SelectAll()

part which is the built in SME MXS way of doing it. But can figure out why.

PS.
Pixamoon, your code for selecting works but this doesn't.

Perhaps someone could shed some light on this issue?

/* LAYOUT VIEW START */

SMEwin = (windows.getChildHWND 0 "Slate Material Editor")[1] -- Get the HWND of the Slate Material Editor
SMElayout = (windows.getChildrenHWND SMEwin)[19][1] -- Get the HWND of the current Layout All button, 16th item in the SMEWin children array
nodeViewImp.SetFocus()

/* SelectAll() Doesn't work */
nodeViewImp.SelectAll()

windows.sendMessage SMEwin 0x111 40048 0 -- toggle Hide Unused Nodeslots
UIAccessor.PressButton SMElayout
nodeViewImp.SelectNone()

/* LAYOUT VIEW END */

.

jahman · 2018-02-24

Can you test if it works for you?


windows.sendMessage SMEwin 0x111 40048 0 -- toggle Hide Unused Nodeslots
windows.sendMessage SMEwin 0xC752 0 0 -- apply changes??

Cheers all

3dwannab · 2018-02-08

I have spy but never really used it.

I'll test these 2 out tomorrow. Hopefully they work when SME isin't open. Both look good.

I'll report back then.

.

jahman · 2018-02-08

select the nodes and then hide unused nodes.
do you mean hide unused nodeslots of selected nodes?

Yes,

3dwannab · 2018-02-08

I can already press the layout all button on the toolbar through maxscript but not the menu where select all is.

`

pixamoon · 2018-02-08

Hi there,

try this:


function SMESelectAll = (    
	local sme_av = sme.activeView
	local viewNode = sme.GetView sme_av

	for n = 1 to trackViewNodes[#sme][sme_av].numSubs do (
		m = trackViewNodes[#sme][sme_av][n].reference
		b = viewNode.GetNodeByRef m
		b.selected = true
	)
)

SMESelectAll()

Best,
Pixamoon

3dwannab · 2018-02-13

Ah man! I should of thought of that method and me already knew it! You're still a lifesaver! Thanks.

EDIT OR, which doesn't seem to work as well as your method.

nodeViewImp = sme.GetView sme.activeView
nodeViewImp.SelectAll()
nodeViewImp.ZoomExtents() #all

.

jahman · 2018-02-08

You can use Spy++ to check what messages are used to toggle various SME commands.

windows.sendMessage <smeHWND> 0x111 40048 0 -- toggle Hide Unused Nodeslots
windows.sendMessage <smeHWND> 0x111 40023 0 -- select ALL

otherwise you need to set view in focus before calling actionMan.executeAction


<viewNode>.SetFocus()

3dwannab · 2018-02-13

Cool.

This works. Never thought it could be a focus issue. Makes sense, thanks.


local sme_av = sme.activeView
local viewNode = sme.GetView sme_av
viewNode.SetFocus()
actionMan.executeAction 369891408 "40063" /* SME: Select All */
actionMan.executeAction 369891408 "40075" /* SME: Hide Unused Nodeslots */
actionMan.executeAction 369891408 "40064" /* SME: Select None */
actionMan.executeAction 369891408 "40060" /* arrange the view */