[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.
it’s possible with extra assembly.
get LayerManager dialog HWND
find SysListView32 child (should be the first)
using SendMessage:
- get total number of items
- go through all of them and find selected
- 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.
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.
You can check out my Layer Explorer extension.