Notifications
Clear all

[Closed] Get all selected modifiers from stack

Here is an interesting one… the modpanel.getCurrentObject() only returns one modifier even if multiple ones are selected. Does anyone know of ahack to get all the selected ones?

25 Replies

selected modifiers make sense only as UI solution. there is no flag (as i know) that indicates that a modifier selected in the stack.

so … the trick can be to find ListBox control of modifier stack, and check what items are selected. after that use these indexes to get modifiers from the currently selected object.

you have also check the command mode, number of selected nodes, etc.

but the idea is:

-- get "Command Panel" hwnd
hwnd = (windows.getChildHWND #max "Command Panel")[1]
-- get modifier stack listbox hwnd
list_box = for c in windows.getChildrenHWND hwnd where c[4] == "ListBox" do exit with c[1]
-- get listbox selected items
count = windows.SendMessage list_box LB_GETCOUNT 0 0
items = for i=0 to count-1 where (windows.SendMessage 0x001004F6 LB_GETSEL i 0) == 1 collect (i+1)
-- get modifiers
for k in items collect (if k > $.modifiers.count then $.baseobject else $.modifiers[k])

Awesome! Here’s a working version of it, only valid output when modify panel is active.


 LB_GETCOUNT= 0x18B
 LB_GETSEL = 0x187
 
hwnd = (windows.getChildHWND #max "Command Panel")[1]
list_box = for c in windows.getChildrenHWND hwnd   where  c[4] == "ListBox" do exit with c[1]
	 
count = windows.SendMessage list_box LB_GETCOUNT 0 0
 
items = for i=0 to count-1 where (windows.SendMessage  list_box  LB_GETSEL i 0) == 1 collect (i+1)
-- get modifiers

for k in items collect (if k > $.modifiers.count then $.baseobject else $.modifiers[k])

@DenisT – Genius! Could you use the same technique to find out which layers are selected in the Pre-Max2015 layer editor?

And for both scenarios, what happens when the list of items exceeds the height of the listbox? If the item isn’t currently being drawn on-screen does it still get flagged as selected?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

pre-max 2015 layer editor can be easier. it’s .net control probably.

item selection should not be effected by it’s visibility (as well as visibility of listbox itself).

technically it’s possible to read text of items. in case of layers it’s helpful because layers use unique names

I’m trying to find the HWND of the layer manager…

print (windows.getChildrenHWND #max)

Not finding it…

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

root parent is not MAX probably. try to search on child windows.

windows.getChildrenHWND 0

Cheers found it…

print (windows.getChildrenHWND 0)

#(6292968P, 65552P, 477026P, “#32770”, “Layer: 0 (default)”, 477026P, 6292968P, 477026P)

I can get the Hwnd of the SysListView32

(windows.getChildrenHWND 6292968P)[1]
#(1787606P, 6292968P, 6292968P, “SysListView32”, “List1”, 0P, 6292968P, 477026P)

I’m always a bit lost with the dark arts of the windows messages, how do you find out what messages to send???

for SysteListView32 you need another messages… i’ve googled “SysteListView32”.
the first i found http://www.codeproject.com/Questions/238246/Getting-Setting-SysListView-control-items

there i see that another messages have to be used

It might not be so simple if the object has references or if some sub object levels are expanded.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it’s not easy for sure

but we can read text of items… and probably filter ‘modifier items’ using some criteria.

references and multiple-node selection case is tricky. it needs full understanding of what the system shows in modifier stack in these cases.

but as i said. i don’t know any other why (including using of sdk) to get a list of selected modifiers

Weird find, if you rename a modifier to “RefObj” it makes its height half.

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0
(@funky_koval)
Joined: 10 months ago

Posts: 0

That’s probably the (hidden) name of the “modifier” item that gets added when you reference an object – it’s half-height too.

RefObj = Reference Object?

Page 1 / 2