Skip To Content

MapLayer.Get (.NET)

This method returns the map or imagery layer properties for the specified map or imagery layer referenced by its map index number..

Declaration

public Dictionary<string, object> Esri.ArcGISForAutoCAD.MapLayer.Get(Document doc, int mapLayerId)

Parameters

TypeNameDescriptionRequired

Document

doc

The AutoCAD document to act on.

required

int

mapLayerId

The index integer number associated with the layer that can be obtained using MapLayer.Names

required

Returns

TypeDescription

Dictionary<string, object>

A dictionary of the map or imagery layer properties. The properties will vary depending on the service. Keys and values of the dictionary are described in the table below.

The dictionary may contain the following values and others:

KeyTypeValue Description

"Allow_Raster_Function"

bool

Whether the layer supports raster functions or not.

"Dynamic"

bool

Method of updating the map layer when the view changes (true = Dynamic, false = Refresh on demand).

"DatumTransformations"

IEnumerable<Dictionary<string, object>>

A collection of dictionaries containing the datum transformation steps.

"Id"

int

The index integer number associated with the layer.

"IsConnected"

bool

Whether the layer is connected or not.

"Name"

string

The name of the map or imagery layer.

"ProcessingTemplate"

string

The imagery layer processing template name.

"ProcessingTemplateNames"

IEnumerable<string>

A collection of available imagery layer processing template names.

"SpatialReference"

string

The spatial reference of the layer as WKID or WKT string.

"Transparency"

int

Percentage of image transparency applied to the map (0-99, zero is opaque).

"Visible"

bool

The visibility of the map (true = Visible, false = Hidden)

Remarks on error conditions

This method can throw an exception or may return null if a parameter is invalid.

Example 1

Print the map layer properties for the index 1 map layer.

// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var mapLayerId = 1;

// Get the map layer properties 
var mapLayerProperties = Esri.ArcGISForAutoCAD.MapLayer.Get(doc, mapLayerId);

// Print the map layer properties 
foreach (var property in mapLayerProperties)
{
  if (property.Key == "DatumTransformations")
  {
    doc.Editor.WriteMessage("\n{0}: ", property.Key);
    foreach (var value in property.Value as IEnumerable<Dictionary<string, object>>)
    {
      doc.Editor.WriteMessage("\nFrom {0}: To {1}", value["From"], value["To"]);
      doc.Editor.WriteMessage("\nTransformation:");
      foreach (var dict in value["Steps"] as List<Dictionary<string, object>>)
      {
        foreach (var kvp in dict)
        {
          doc.Editor.WriteMessage("\n\t{0}: {1}", kvp.Key, kvp.Value);
        }
      }
    }
    continue;
  }
  doc.Editor.WriteMessage("\n{0}: {1}", property.Key, property.Value);
}

/* Example output 
Id: 1
Name: ThreeLayers
ItemType: MapImageServiceLayer
IsConnected: True
ServiceUri: https://cadserver.esri.com/server/rest/services/afaHarness/ThreeLayers/MapServer
SpatialReference: 3857
Sublayer_0_Name: myGroupOfLayers
Sublayer_0_Visible: True
Sublayer_1_Name: ETH_ThreeLayers_6543
Sublayer_1_Visible: True
Sublayer_1_SourceSpRef: 103122
Sublayer_2_Name: ETH_ThreeLayers_2882
Sublayer_2_Visible: True
Sublayer_2_SourceSpRef: 2882
Sublayer_3_Name: ETH_ThreeLayers_6425
Sublayer_3_Visible: True
Sublayer_3_SourceSpRef: 103002
Visible: True
Transparency: 30
Dynamic: True
DatumTransformations:
From 6543: To 3857
Transformation:  
 Direction: Reverse
 Step: 108354
From 2882: To 3857
Transformation:
 Direction: Forward
 Step: 1901
*/

Example 2

Print the imagery layer properties for the index 2 imagery layer..

// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var layerId = 2;

// Get the imagery layer properties 
var imageryLayerProperties = Esri.ArcGISForAutoCAD.MapLayer.Get(doc, layerId);

// Print the imagery layer properties 
foreach (var property in imageryLayerProperties)
{
  if (property.Key == "ProcessingTemplateNames")
  {
    doc.Editor.WriteMessage("\n{0}:", property.Key);
    foreach (var value in property.Value as List<string>)
    {
      doc.Editor.WriteMessage(" " + value);
    }
    continue;
  }
  doc.Editor.WriteMessage("\n{0}: {1} ", property.Key, property.Value);
}

/* Example output 
Id: 2
Name: CharlotteLAS
ItemType: RasterServiceLayer
IsConnected: True
ServiceUri: https://sampleserver6.arcgisonline.com/arcgis/rest/services/CharlotteLAS/ImageServer
SpatialReference: 102719
Visible: True
Transparency: 30
Dynamic: True
Allow_Raster_Function: True
ProcessingTemplateNames: None RFTAspectColor RFTHillshade RFTShadedReliefElevationColorRamp
*/

See also

MapLayer.Names —A .NET method that returns an indexed dictionary of map and imagery layer names included in the current drawing.

esri_maplayer_get —An AutoLISP function that returns the map or imagery layer properties for the specified layer index number.