<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Best Way to Programmatically Identify a Coordinate System? in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13706871#M26533</link>
    <description>&lt;P&gt;I retrieve the coordinate system code using this method&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[CommandMethod ("printCoordinate")]
public static void PrintCoordinateSystemCode()
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    var ed = doc.Editor;
    var civDoc = CivilApplication.ActiveDocument;

    // getCoordinateSystemCode
    string csCode = civDoc.Settings
                            .DrawingSettings
                            .UnitZoneSettings
                            .CoordinateSystemCode;

    if (string.IsNullOrEmpty(csCode))
    {
        ed.WriteMessage("\nNo coordinate system is set for this drawing.");
    }
    else
    {
        ed.WriteMessage($"\nCurrent coordinate system code: {csCode}");
    }
}&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 02 Jul 2025 02:24:56 GMT</pubDate>
    <dc:creator>rampseeker</dc:creator>
    <dc:date>2025-07-02T02:24:56Z</dc:date>
    <item>
      <title>Best Way to Programmatically Identify a Coordinate System?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13616847#M51</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking for some guidance here. The overarching question is:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;What is the best way to programmatically identify a coordinate system?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I understand that there are Projected, Geodetic, Arbitrary, etc ...Coordinate Systems. So perhaps for sake of taking a first step, the question could be:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;What is the best way to programmatically identify a &lt;FONT color="#000000"&gt;projected&lt;/FONT&gt; coordinate system?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It should also be assumed that enough information necessary to identify the coordinate system is present (e.g. Ellipsoid name/flattening/radius/etc, Projection scale/false northing/false easting/etc, Datum name/realization/etc). Also, the data can be in any format necessary (JSON, XML, WKT, etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So even if I have all of this data, &lt;STRONG&gt;HOW&lt;/STRONG&gt; can I programmatically (using any programming language, ideally .NET or Python) output, with &lt;STRONG&gt;##%&lt;/STRONG&gt; confidence, something like:&lt;BR /&gt;- EPSG 2232&lt;/P&gt;&lt;P&gt;- Custom CS, based on EPSG 2232&lt;/P&gt;&lt;P&gt;- Arbitrary CS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to ultimately retrieve this information from a source, open Civil 3D, and automatically assign a coordinate system (assuming I have sufficient information/confidence to do so).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As always, any input is appreciated.&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2025 20:19:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13616847#M51</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2025-05-06T20:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Best Way to Programmatically Identify a Coordinate System?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13706871#M26533</link>
      <description>&lt;P&gt;I retrieve the coordinate system code using this method&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[CommandMethod ("printCoordinate")]
public static void PrintCoordinateSystemCode()
{
    var doc = Application.DocumentManager.MdiActiveDocument;
    var ed = doc.Editor;
    var civDoc = CivilApplication.ActiveDocument;

    // getCoordinateSystemCode
    string csCode = civDoc.Settings
                            .DrawingSettings
                            .UnitZoneSettings
                            .CoordinateSystemCode;

    if (string.IsNullOrEmpty(csCode))
    {
        ed.WriteMessage("\nNo coordinate system is set for this drawing.");
    }
    else
    {
        ed.WriteMessage($"\nCurrent coordinate system code: {csCode}");
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Jul 2025 02:24:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13706871#M26533</guid>
      <dc:creator>rampseeker</dc:creator>
      <dc:date>2025-07-02T02:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Best Way to Programmatically Identify a Coordinate System?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13706893#M26534</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/15547724"&gt;@rampseeker&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply! I can easily get the CS Code with the System Variable CGEOCS. My main goal is rather identifying a system by all of it's definition properties. In essence, if I had everything BUT the CGEOCS code, how would I determine a CGEOCS code lol&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&amp;nbsp;&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2025 02:52:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13706893#M26534</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2025-07-02T02:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Best Way to Programmatically Identify a Coordinate System?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13707416#M26538</link>
      <description>&lt;P&gt;You can request the current Coordinate System with this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public static acDbServ.GeoCoordinateSystem GetCurrentCoordinateSystem()
        {

            acDbServ.GeoCoordinateSystem returnValue = null;
            string name = string.Empty;

            acDbServ.Database db = acAppServ.Application.DocumentManager.MdiActiveDocument.Database;
            using (acDbServ.Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    if (db.GeoDataObject != acDbServ.ObjectId.Null)
                    {
                        acDbServ.GeoLocationData gd = tr.GetObject(db.GeoDataObject, acDbServ.OpenMode.ForRead) as acDbServ.GeoLocationData;

                        Match matchName = Regex.Match(gd.CoordinateSystem, "&amp;lt;Name&amp;gt;(.*?)&amp;lt;/Name&amp;gt;");
                        if (matchName.Success)
                        {
                            name = matchName.Groups[1].Value;
                        }

                        if (name != string.Empty)
                        {
                            foreach (acDbServ.GeoCoordinateSystem cs in acDbServ.GeoCoordinateSystem.CreateAll())
                            {
                                if (cs.ID == name)
                                {
                                    returnValue = cs;
                                    break;
                                }
                            }
                        }
                    }
                }
                catch (System.Exception ex) { }

                tr.Commit();
            }

            return returnValue;
        }&lt;/LI-CODE&gt;&lt;P&gt;The returned object can be read further, if I remember correctly, you can see if it is projected and read the WKT stuff and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want all 6000+ available Coordinate Systems, you can use this code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;       public static List&amp;lt;acDbServ.GeoCoordinateSystem&amp;gt; GetAllValidCoordinateSystems()
        {

            List&amp;lt;acDbServ.GeoCoordinateSystem&amp;gt; returnValue = new List&amp;lt;acDbServ.GeoCoordinateSystem&amp;gt;();

            List&amp;lt;string&amp;gt; ignoreItems = new List&amp;lt;string&amp;gt;() { "obsolete", "deprecated", "replaced by", "for testing only", "incorrect", "legacy use" };

            foreach (acDbServ.GeoCoordinateSystem cs in acDbServ.GeoCoordinateSystem.CreateAll())
            {
                if (cs.Type == acDbServ.GeoCSType.Projected)
                {
                    string description = cs.Description.Trim().ToLower();
                    if (ignoreItems.Any(s =&amp;gt; description.Contains(s)) == false) { returnValue.Add(cs); }
                }
            }

            return returnValue;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2025 09:39:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13707416#M26538</guid>
      <dc:creator>Anton_Huizinga</dc:creator>
      <dc:date>2025-07-02T09:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Best Way to Programmatically Identify a Coordinate System?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13707605#M26543</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1948693"&gt;@Anton_Huizinga&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's useful information! I'm semi familiar with retrieving the CS Dictionary XML data. Perhaps this would be one step of the entire process. But my question would still remain:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;If I had everything BUT the CGEOCS code, how would I determine a CGEOCS code?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's a very nuanced question and definitely not easy to answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&amp;nbsp;&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2025 11:31:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13707605#M26543</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2025-07-02T11:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Best Way to Programmatically Identify a Coordinate System?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13707623#M26544</link>
      <description>&lt;P&gt;I guess you could walk through all available CS and then compare as many as values.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2025 11:40:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/best-way-to-programmatically-identify-a-coordinate-system/m-p/13707623#M26544</guid>
      <dc:creator>Anton_Huizinga</dc:creator>
      <dc:date>2025-07-02T11:40:10Z</dc:date>
    </item>
  </channel>
</rss>

