Is there a way to get a list of the coordinate systems that are available to the Civil 3D drawing i.e. how can I access the list found in the Drawing Settings>Units and Zone>Zone section as shown in the screenshot below ?
We can access the list of available coordinate systems using Geospatial Platform API which is part of AutoCAD Map 3D. As you know, AutoCAD Civil 3D is built on top of AutoCAD Map 3D and we can use the available Map 3D functionalities and API features in building custom application running on AutoCAD Civil 3D as well. To get the list of all the available Coordinate systems in a Drawing file in AutoCAD Civil 3D, we need to use MgCoordinateSystemFactory from OSGeo.MapGuide namespace. And for that you need to reference the following assemblies from 'AutoCAD Civil 3D 2014' installation folder -
- OSGeo.MapGuide.Foundation.dll
- OSGeo.MapGuide.PlatformBase.dll
- OSGeo.MapGuide.Geometry.dll
Here is the C# .NET code snippet -
MgCoordinateSystemFactory coordSysFactory = newMgCoordinateSystemFactory();
MgCoordinateSystemCatalog csCatalog = coordSysFactory.GetCatalog();
MgCoordinateSystemDictionary csDict = csCatalog.GetCoordinateSystemDictionary();
MgCoordinateSystemEnum csDictEnum = csDict.GetEnum();
int csCount = csDict.GetSize();
ed.WriteMessage("\nCoordinate System Count : " + csCount.ToString());
ed.WriteMessage("\n-------------------------------------------------");
MgStringCollection csNames = csDictEnum.NextName(csCount);
string csName = null;
MgCoordinateSystem cs = null;
for (int i = 0; i < csCount; i++)
{
csName = csNames.GetItem(i);
cs = csDict.GetCoordinateSystem(csName);
ed.WriteMessage("\nCoordinate System Name : " + csName.ToString() + " " + "CS Code : " + cs.CsCode.ToString());
ed.WriteMessage("\n-------------------------------------------------");
}
and Result in AutoCAD Civil 3D -