Notifications
Clear all

[Closed] Get current selected Layer

Hello,

is it possible to get the Layer which is currently selected?

LayerManager.current 

This just gives me the current active layer.

But i want that layer which i just have selected in the layer manager.

10 Replies

I don’t think it’s currently possible… Annoyingly

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it’s possible with extra assembly.

get LayerManager dialog HWND

find SysListView32 child (should be the first)

using SendMessage:

  1. get total number of items
  2. go through all of them and find selected
  3. get text of selected items for first column

so it’s doable. but question is – why do you need to know selected layer?

Thanks.

But I figured it out:

tmp = SceneExplorerManager.GetActiveExplorer()
layer = tmp.SelectedItems()
layer[1].name

Edit:
@denis
I am currently working on a little renaming tool for our studio.
So it is very handy, to be able to rename a layer and its nodes by selecting it and pressing a button.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

Scene Explorer is not the same as Layer Manager. I don’t know how you can get selected layer from using scene explorer selection

Yes very strange indeed.

That’s how i came upon this:

If I rightclick on a layer in the layer manager and click “select child nodes”, following macro will execute:

macros.run "Scene Explorer" "SESelectChildren"

Then I looked up that macro script:

macroScript SESelectChildren
	category:~SCENEEXPLORER_GROUP~
	internalCategory: "Scene Explorer" --LOC_NOTES: do not localize this
	toolTip:~SEQ_SELECT_CHILDREN_TT~ --LOC_NOTES: localize this
	ButtonText:~SEQ_SELECT_CHILDREN~ --LOC_NOTES: localize this

(	
	
	on isVisible do	(
		sceneExplorerInstance = SceneExplorerManager.GetActiveExplorer()
		return (	sceneExplorerInstance != undefined )
	)
	
	on isEnabled do 	(
		sceneExplorerInstance = SceneExplorerManager.GetActiveExplorer()
		if (sceneExplorerInstance == undefined) then return false
		count = (sceneExplorerInstance.SelectedItems()).Count
		return (	(sceneExplorerInstance != undefined) and ( count > 0) )
	)
	
	on execute do
	(
		sceneExplorerInstance = SceneExplorerManager.GetActiveExplorer()
		sceneExplorerInstance.SelectChildren()
	)
)

So it seems like Autodesk is using the SceneExplorer to access the layer manager as well.
Whatever it’s working.

Is this 3dsmax 2015 or before?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

probably it’s only 2015. all versions before don’t work for me.

Oh, your are right.
It’s just working in Max 2015

Yes they completely re-wrote the Layer Manager system in 2015.

You can check out my Layer Explorer extension.

http://cganimator.com/cslayerexplorer-extension-v1-0/