Skip To Content

CoordinateSystem.Set (.NET)

This method sets the coordinate system of the current drawing by specifying the path to a valid Esri .prj file or well-known ID (WKID).

Note:

Coordinate systems cannot be set when the drawing contains web feature layers.

Note:

ArcGIS for AutoCAD requires its own coordinate system information distinct and separate from any AutoCAD coordinate system or geolocation information. When working within Civil 3D whenever ArcGIS for AutoCAD sets an Esri coordinate system it will also attempt to set a matching Civil 3D GEODATA coordinate system, if one is not already set.

Declaration

public string Esri.ArcGISForAutoCAD.CoordinateSystem.Set(Document doc, string coordinateSystemInfo)

Parameters

TypeNameDescriptionRequired

Document

doc

The AutoCAD document to act on.

required

string

coordinateSystemInfo

A valid WKID of an Esri coordinate system as a string or the path to a valid Esri coordinate system definition .prj file.

required

Returns

TypeDescription

string

The coordinate system definition.

Remarks on error conditions

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

Example 1

Set the Esri coordinate system to the definition contained in the WGS_1984_Web_Mercator_Auxiliary_Sphere.prj file and print the resulting coordinate system definition.

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

// Set the Esri coordinate system with the .prj file
var newCoordSys = Esri.ArcGISForAutoCAD.CoordinateSystem.Set(doc, @"C:\CADwork\WGS_1984_Web_Mercator_Auxiliary_Sphere.prj");

// Print the coordinate system definition
doc.Editor.WriteMessage(newCoordSys);

/* Example output 
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]
*/

Example 2

Set the Esri coordinate system using the WKID number 3857 and print the resulting coordinate system definition.

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

// Set the Esri coordinate system using the WKID
var newCoordSys = Esri.ArcGISForAutoCAD.CoordinateSystem.Set(doc, "3857");

// Print the coordinate system definition
doc.Editor.WriteMessage(newCoordSys);

/* Example output
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]
*/

See also

esri_coordsys_set—An AutoLISP function that sets the coordinate system of the current drawing by specifying the path to a valid Esri .prj file or WKID.