Get selected Layer

Get selected Layer

elpie89
Advocate Advocate
1,804 Views
6 Replies
Message 1 of 7

Get selected Layer

elpie89
Advocate
Advocate

I'm using the dialog displayed by

Global.COREInterface14.DoHitByNameDialog(null);

 

I would like to retrieve the list of Selected Layers in that panel

 

Is it possible? I can't find any way.

Do you have some advice?

thanks

0 Likes
Accepted solutions (1)
1,805 Views
6 Replies
Replies (6)
Message 2 of 7

istan
Advisor
Advisor

This is the standard node selection dialog, returning you a list of nodes, or?

Why don't you then iterate on the selected nodes with

GetLayerFromNode()

to get all affected layers?

 

0 Likes
Message 3 of 7

denisT.MaxDoctor
Advisor
Advisor

@istan wrote:

This is the standard node selection dialog, returning you a list of nodes, or?

Why don't you then iterate on the selected nodes with

GetLayerFromNode()

to get all affected layers?

 


usually when anyone asks about "selected layer", it means a layer selected in Layer Manager. In this case it might be a situation when no one node is selected but a layer is

0 Likes
Message 4 of 7

elpie89
Advocate
Advocate

Thanks @denisT.MaxDoctor to explain that.

You get the point...yes I need only the layers selected in the layer manager

0 Likes
Message 5 of 7

denisT.MaxDoctor
Advisor
Advisor

@elpie89 wrote:

Thanks @denisT.MaxDoctor to explain that.

You get the point...yes I need only the layers selected in the layer manager


so "layer selection" makes sense only when Layer Explorer is open.

You have to find Layer Manager Dialog as .net control. Find the TreeList which is SceneExplorerTreeList.

It's an expension of DevX XtraTreeList.

To get selected nodes use Selection property.

To get the count  XtraTreeList.Selection.Count

To get a node XtraTreeList.Selection.get_item(<0 based index>) 

To get a node name (the Layers's name)  XtraTreeList.Selection.get_item(n).GetValue 0

 

i'm prety sure the MAX provides easy access to Layer Explorer dialog. But i don't forgot how and not really interested right now to remember 🙂

 

0 Likes
Message 6 of 7

elpie89
Advocate
Advocate

I still struggling on this, I was out the entire week actually.

So after a day, I figured out a there is a bunch of dll that I should use for this task

 

https://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__files_GUID_A08A117C_9D15_4044_BC29_3AD9F8AFD9...

 

 

and I found some documentation here

http://download.autodesk.com/global/docs/3dsmaxsdk2012/en_us/index.html?url=dotnet_ref/class_max_cus...

 

I can't found the same page for max 2019

 

Anyway, my problem now is that I can't find the famous SceneExplorerTreeList.

it should be in some method of SceneExplorer.dll

I'll probably find it tomorrow but if you have some info please let me know.

You already helped a lot redirecting me to the right classes

Thanks

 

 

0 Likes
Message 7 of 7

elpie89
Advocate
Advocate
Accepted solution

I found a way:

private SceneExplorerDialog sceneExplorer;

....

if (!sceneExplorer.Visible)
{
sceneExplorer.Closed += SceneExplorerOnClosed;
sceneExplorer.Show();
}

....

private void SceneExplorerOnClosed(object sender, EventArgs e)
{
TraversalNode[] traversalNodes = sceneExplorer.ExplorerControl.GetSelectedNodes(false, false, false);
foreach (TraversalNode traversalNode in traversalNodes)
{
if (INodeUtilities.IsMaxLayerTraversalNode(traversalNode))
{
ITraversalILayer layer = (ITraversalILayer) traversalNode;
MessageBox.Show(layer.SceneName);
}
}
}

and of course, the name of the layer is accessed with layer.SceneName

make sense😂

 

Thanks a lot 

 

 

 

0 Likes