Accessing Layer names from the selected FDO Features

By Partha Sarkar

When you select a FDO feature in Map 3D, you want to know the corresponding layer name as shown in Map 3D display Manager. How to do this using Map 3D Geospatial Platform API ?

Img1

We can use the MgSelectionBase.GetLayers() API to get the layers name for the selected FDO features in Map 3D. Here is a C#.NET code snippet for the same:

// Get the Map Object
AcMapMap currentMap = AcMapMap.GetCurrentMap();
MgLayerCollection layers = currentMap.GetLayers();
 
//select feature on Map
PromptSelectionResult selResult = ed.GetSelection();
if (selResult.Status == PromptStatus.OK)
{
    SelectionSet selSet = selResult.Value;
    MgSelectionBase selectionBase = AcMapFeatureEntityService.GetSelection(selSet);
 
    foreach (MgLayerBase layer in selectionBase.GetLayers())
    {
        ed.WriteMessage("nFeature selected from Layer :" + layer.Name.ToString());
    }
}

 


Comments

One response to “Accessing Layer names from the selected FDO Features”

  1. Firexoulz Avatar
    Firexoulz

    Hello.. can you give a sample codes on vb.net of how to connect vb.net on autocad map 3d. Thank you! hope you continue sharing your knowledge. :)

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading