Notifications
Clear all
[Closed] Get Selected Layers (3dsmax 2014 and below)
Page 2 / 2
Prev
Jan 28, 2016 11:36 am
Well… highlighted layers are layers that has selected objects.
for o in selected collect o.layer
will give you highlighted layers.
1 Reply
Yep, but you can’t press/make a button to make those highlighted layers selected it would seem. I’ve told Autodesk to sort it out but I doubt we’ll see it for 2017 as apparently it was too late…
Jan 28, 2016 11:36 am
Very rudimentary, but if it does what you need we can work on improving it.
(
fn SelectNodesLayers keepSelection:false =
(
layerExplorer = (for o in (windows.getChildrenHWND 0) where o[5] == "Scene Explorer - Layer Explorer" do exit with o)[1]
layerExplorerControls = windows.getChildrenHWND layerExplorer
ctrl = dotnetclass "System.Windows.Forms.Control"
richSceneExplorer = ctrl.FromHandle (dotnetobject "System.Intptr" layerExplorerControls[4][1])
if (maxversion())[1] >= 18000 then
(
selected = richSceneExplorer.GetSelectedNodes false false false
)else(
selected = richSceneExplorer.GetSelectedNodes()
)
layerClass = dotnet.gettype "SceneExplorer.TraversalLayerBaseNode"
--nodeClass = dotnet.gettype "SceneExplorer.TraversalSceneNode"
if keepSelection==false do richSceneExplorer.ClearNodeSelection()
done = #()
for j in selected do
(
parent = j.ParentNode
if finditem done parent == 0 do
(
if dotnet.gettype j == layerClass do parent = j
try (richSceneExplorer.SelectNode parent) catch()
append done parent
)
)
)
SelectNodesLayers keepSelection:false
)
EDIT1: Fixed bug where selected layers with no selected nodes would be unselected.
Jan 28, 2016 11:36 am
Glad it worked.
Here is a little better version that includes an option to select all the layer objects.
(
fn IsLayerExplorerOpen =
(
return SceneExplorerManager.ExplorerIsOpen "Layer Explorer"
)
fn GetLayerExplorerHWND =
(
if IsLayerExplorerOpen() do
(
layerExplorer = (for o in (windows.getChildrenHWND 0) where o[5] == "Scene Explorer - Layer Explorer" do exit with o)[1]
layerExplorerControls = windows.getChildrenHWND layerExplorer
return dotnetobject "System.Intptr" layerExplorerControls[4][1]
)
return undefined
)
fn SelectNodesLayers selectNodes:#none =
(
version = (maxversion())[1]
if version < 17000 do return messagebox "Unsupported 3ds Max version."
hwnd = GetLayerExplorerHWND()
if hwnd == undefined do return messagebox "Layer Explorer is not open."
richSceneExplorer = (dotnetclass "System.Windows.Forms.Control").FromHandle hwnd
if version >= 18000 then
(
selected = richSceneExplorer.GetSelectedNodes false false false
)else(
selected = richSceneExplorer.GetSelectedNodes()
)
layerClass = dotnet.gettype "SceneExplorer.TraversalLayerBaseNode"
done = #()
for j in selected do
(
parent = j.ParentNode
if finditem done parent == 0 do
(
if dotnet.gettype j == layerClass do parent = j
append done parent
)
)
if selectNodes == #none do richSceneExplorer.ClearNodeSelection()
for j in done do richSceneExplorer.SelectNode j
if selectNodes == #all do for j in done do richSceneExplorer.SelectNodes j.Children
)
SelectNodesLayers selectNodes:#all--[#none|#keep|#all]
)
Page 2 / 2
Prev