The MapLayer.Extract method converts a visible Esri map or imagery layer into a standard AutoCAD raster graphic and stores it as a graphics file in the specified file directory. The map layer or imagery layer must be visible in the drawing. The map layer remains in the drawing after extraction. To remove a map layer, use the MapLayer.Remove method.
Declaration
public bool Esri.ArcGISForAutoCAD.MapLayer.Extract(Document doc, int mapLayerId, string imageFilePath)
Parameters
| Type | Name | Description | Required |
|---|---|---|---|
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 |
string | imageFilePath | The file path to the new image file that is created from the specified map or imagery layer. This parameter overwrites the file unless the file is currently open or otherwise being used by another resource. | required |
Returns
| Type | Description |
|---|---|
bool | true if the map or imagery layer was extracted successfully |
Remarks on error conditions
This method may throw an exception or return false or null if a parameter is invalid.
Example
Print the success of extracting the map or imagery layer with the index number of 2 as a PNG image named myExtractedLayer.png.// Initialize
var doc = Application.DocumentManager.MdiActiveDocument;
var mapLayerId = 2;
var imageFilePath = @"C:\myExtractedData\myExtractedLayer.png";
// Extract the map layer
var success = Esri.ArcGISForAutoCAD.MapLayer.Extract(doc, mapLayerId, imageFilePath);
// Print the success
doc.Editor.WriteMessage(success.ToString());
/* Example output
True
*/
See also
MapLayer.Names—A .NET method that returns an indexed dictionary of map and imagery layer names included in the current drawing.
MapLayer.Remove—A .NET method that removes the specified map or imagery layer referenced by its map index number.
esri_maplayer_extract—An AutoLISP function that converts a visible Esri map or imagery layer into a standard AutoCAD raster graphic and stores it as a graphics file in the specified file directory.