<?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: SetGeoCoordinateSystem in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13278167#M1307</link>
    <description>&lt;P&gt;Great! Congratulations on resolving it, and thank you for your appreciation and sharing your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jan 2025 13:58:28 GMT</pubDate>
    <dc:creator>jeremy_tammik</dc:creator>
    <dc:date>2025-01-23T13:58:28Z</dc:date>
    <item>
      <title>SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13277799#M1303</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be interested in changing the Revit geolocation system; from the UI it's only possible by importing a CAD file but I would like to be able to do it programmatically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the method &lt;A href="https://www.revitapidocs.com/2024/d7b1a7b0-5e52-46e3-cef0-d1e2e017122a.htm" target="_blank" rel="noopener"&gt;SiteLocation.SetGeoCoordinateSystem()&lt;/A&gt; and looks like what I need, but I don't understand how to use the method's argument. Is there a list of possible codes that I can use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 11:03:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13277799#M1303</guid>
      <dc:creator>h_echevarria</dc:creator>
      <dc:date>2025-01-23T11:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13277900#M1304</link>
      <description>&lt;P&gt;Hello Hernan.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I passed on your question to an LLM, as I described today in my blog:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2025/01/access-to-uiapplication-tags-and-llm-api-support.html#2" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2025/01/access-to-uiapplication-tags-and-llm-api-support.html#2&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It replies:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="model-response-message-contentr_3b003b223f84c805" class="markdown markdown-main-panel stronger" dir="ltr"&gt;
&lt;P data-sourcepos="1:1-1:56"&gt;&lt;STRONG&gt;Subject: Programmatically Changing Revit Geolocation&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-sourcepos="3:1-3:10"&gt;&lt;STRONG&gt;Hello,&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-sourcepos="5:1-5:204"&gt;You're right, the Revit UI only allows setting geolocation by importing a CAD file, which can be cumbersome. Fortunately, the &lt;CODE&gt;SiteLocation.SetGeoCoordinateSystem()&lt;/CODE&gt; method offers a programmatic solution.&lt;/P&gt;
&lt;P data-sourcepos="7:1-7:55"&gt;&lt;STRONG&gt;Understanding the &lt;CODE&gt;SetGeoCoordinateSystem()&lt;/CODE&gt; Method&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-sourcepos="9:1-9:218"&gt;This method requires a &lt;CODE&gt;string&lt;/CODE&gt; argument representing the &lt;STRONG&gt;EPSG code&lt;/STRONG&gt; (European Petroleum Survey Group code) of the desired coordinate system. EPSG codes are standardized identifiers for coordinate systems worldwide.&lt;/P&gt;
&lt;P data-sourcepos="11:1-11:22"&gt;&lt;STRONG&gt;Finding EPSG Codes&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL data-sourcepos="13:1-16:0"&gt;
&lt;LI data-sourcepos="13:1-14:0"&gt;
&lt;P data-sourcepos="13:4-13:182"&gt;&lt;STRONG&gt;EPSG Registry:&lt;/STRONG&gt; The official source is the EPSG Registry. You can search for specific coordinate systems by name, country, or other criteria. This provides the exact EPSG code.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-sourcepos="15:1-16:0"&gt;
&lt;P data-sourcepos="15:4-15:186"&gt;&lt;STRONG&gt;Spatial Reference Systems:&lt;/STRONG&gt; Many online resources and libraries (like Proj4) maintain databases of spatial reference systems. These can often be used to find equivalent EPSG codes.&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P data-sourcepos="17:1-17:16"&gt;&lt;STRONG&gt;Example Code&lt;/STRONG&gt;&lt;/P&gt;
&lt;DIV class="code-block ng-tns-c1602499850-16 ng-trigger ng-trigger-codeBlockRevealAnimation"&gt;
&lt;DIV class="code-block-decoration ng-tns-c1602499850-16 header-formatted gds-title-s ng-star-inserted"&gt;&lt;SPAN class="ng-tns-c1602499850-16"&gt;C#&lt;/SPAN&gt;
&lt;DIV class="buttons ng-tns-c1602499850-16 ng-star-inserted"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="ng-tns-c1602499850-16 formatted-code-block-internal-container"&gt;
&lt;DIV class="animated-opacity ng-tns-c1602499850-16"&gt;
&lt;PRE class="ng-tns-c1602499850-16"&gt;&lt;CODE class="code-container ng-tns-c1602499850-16 formatted" role="text" data-test-id="code-content" data-sourcepos="19:1-39:1"&gt;&lt;SPAN class="hljs-keyword"&gt;using&lt;/SPAN&gt; Autodesk.Revit.DB;

&lt;SPAN class="hljs-comment"&gt;// Get the active document&lt;/SPAN&gt;
Document doc = DocumentManager.Instance.CurrentDBDocument;

&lt;SPAN class="hljs-comment"&gt;// Get the SiteLocation&lt;/SPAN&gt;
SiteLocation siteLocation = doc.SiteLocation;

&lt;SPAN class="hljs-comment"&gt;// Set the GeoCoordinateSystem using the EPSG code&lt;/SPAN&gt;
&lt;SPAN class="hljs-built_in"&gt;string&lt;/SPAN&gt; epsgCode = &lt;SPAN class="hljs-string"&gt;"EPSG:4326"&lt;/SPAN&gt;; &lt;SPAN class="hljs-comment"&gt;// Example: WGS 84 (latitude/longitude)&lt;/SPAN&gt;
siteLocation.SetGeoCoordinateSystem(epsgCode);

&lt;SPAN class="hljs-comment"&gt;// Save the changes&lt;/SPAN&gt;
&lt;SPAN class="hljs-keyword"&gt;using&lt;/SPAN&gt; (Transaction t = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; Transaction(doc, &lt;SPAN class="hljs-string"&gt;"Set Geolocation"&lt;/SPAN&gt;))
{
    t.Start();
    doc.Regenerate();
    t.Commit();
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P data-sourcepos="41:1-41:28"&gt;&lt;STRONG&gt;Important Considerations&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL data-sourcepos="43:1-46:0"&gt;
&lt;LI data-sourcepos="43:1-43:210"&gt;&lt;STRONG&gt;Coordinate System Accuracy:&lt;/STRONG&gt; Choose the appropriate coordinate system based on your project's location and requirements. Inaccurate geolocation can lead to significant errors in analysis and visualization.&lt;/LI&gt;
&lt;LI data-sourcepos="44:1-44:199"&gt;&lt;STRONG&gt;Project Units:&lt;/STRONG&gt; Ensure your project's units are compatible with the chosen coordinate system. For example, if using latitude/longitude (WGS 84), your project should likely be in decimal degrees.&lt;/LI&gt;
&lt;LI data-sourcepos="45:1-46:0"&gt;&lt;STRONG&gt;Data Validation:&lt;/STRONG&gt; Before setting the geolocation, consider validating the provided EPSG code to prevent unexpected behavior.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P data-sourcepos="47:1-47:24"&gt;&lt;STRONG&gt;Further Enhancements&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL data-sourcepos="49:1-51:0"&gt;
&lt;LI data-sourcepos="49:1-49:167"&gt;&lt;STRONG&gt;User Interface:&lt;/STRONG&gt; Create a custom dialog or form within your add-in to allow users to select the desired coordinate system from a list or by entering an EPSG code.&lt;/LI&gt;
&lt;LI data-sourcepos="50:1-51:0"&gt;&lt;STRONG&gt;Coordinate System Conversion:&lt;/STRONG&gt; If needed, implement functionality to convert coordinates between different systems within your add-in.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P data-sourcepos="52:1-52:24"&gt;&lt;STRONG&gt;Additional Resources&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL data-sourcepos="54:1-56:0"&gt;
&lt;LI data-sourcepos="54:1-54:168"&gt;&lt;STRONG&gt;The Building Coder:&lt;/STRONG&gt; Search for articles related to geolocation and coordinate systems on The Building Coder blog for in-depth discussions and advanced techniques.&lt;/LI&gt;
&lt;LI data-sourcepos="55:1-56:0"&gt;&lt;STRONG&gt;Revit API Documentation:&lt;/STRONG&gt; Refer to the official Revit API documentation for detailed information on the &lt;CODE&gt;SiteLocation&lt;/CODE&gt; class and its methods.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P data-sourcepos="57:1-57:101"&gt;I hope this comprehensive response helps you effectively change Revit's geolocation programmatically!&lt;/P&gt;
&lt;P data-sourcepos="59:1-59:203"&gt;&lt;STRONG&gt;Disclaimer:&lt;/STRONG&gt; This information is provided for guidance and educational purposes. Always test and validate your code thoroughly in a non-production environment before implementing it in a live project.&lt;/P&gt;
&lt;P data-sourcepos="61:1-61:182"&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; This response builds upon the provided information and aims to offer a more complete and practical solution, incorporating best practices and addressing potential concerns.&lt;/P&gt;
&lt;P data-sourcepos="61:1-61:182"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 11:57:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13277900#M1304</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2025-01-23T11:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13277911#M1305</link>
      <description>&lt;P&gt;Oops. The first answer was provided by Gemeni 1.5 Flash. I forgot to click the button to request Gemini 2.0 Flash Experimental, which often generates a more reliable answer. The latter replies more extensively; looking forward to hearing back from you what think of these two answers:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="model-response-message-contentr_90286c68de036d0e" class="markdown markdown-main-panel stronger" dir="ltr"&gt;
&lt;P data-sourcepos="1:1-1:6"&gt;Hello,&lt;/P&gt;
&lt;P data-sourcepos="3:1-3:285"&gt;You're on the right track with &lt;CODE&gt;SiteLocation.SetGeoCoordinateSystem()&lt;/CODE&gt;. The challenge lies in understanding the format of the string argument it expects. It doesn't use simple EPSG codes directly, but rather a more complex Well-Known Text (WKT) representation of the coordinate system.&lt;/P&gt;
&lt;P data-sourcepos="5:1-5:56"&gt;Here's a breakdown of the problem and a robust solution:&lt;/P&gt;
&lt;P data-sourcepos="7:1-7:30"&gt;&lt;STRONG&gt;Understanding the Problem:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-sourcepos="9:1-9:297"&gt;Revit's &lt;CODE&gt;SetGeoCoordinateSystem()&lt;/CODE&gt; doesn't accept EPSG codes directly. It requires a WKT string defining the coordinate system. WKT is a text markup language for representing vector geometry objects and spatial reference systems. Constructing these strings manually can be complex and error-prone.&lt;/P&gt;
&lt;P data-sourcepos="11:1-11:22"&gt;&lt;STRONG&gt;Solution Approach:&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL data-sourcepos="13:1-18:0"&gt;
&lt;LI data-sourcepos="13:1-14:0"&gt;
&lt;P data-sourcepos="13:5-13:291"&gt;&lt;STRONG&gt;Use a Spatial Reference Library:&lt;/STRONG&gt; The most reliable way to handle this is to use a .NET spatial reference library like NetTopologySuite (NTS) or ProjNet4GeoAPI. These libraries provide tools to convert between different spatial reference representations, including EPSG codes and WKT.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-sourcepos="15:1-16:0"&gt;
&lt;P data-sourcepos="15:5-15:110"&gt;&lt;STRONG&gt;EPSG to WKT Conversion:&lt;/STRONG&gt; Use the chosen library to convert the desired EPSG code to its WKT equivalent.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI data-sourcepos="17:1-18:0"&gt;
&lt;P data-sourcepos="17:5-17:102"&gt;&lt;STRONG&gt;Apply WKT to Revit:&lt;/STRONG&gt; Use the resulting WKT string with &lt;CODE&gt;SiteLocation.SetGeoCoordinateSystem()&lt;/CODE&gt;.&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P data-sourcepos="19:1-19:51"&gt;&lt;STRONG&gt;Code Example (using ProjNet4GeoAPI and GeoAPI):&lt;/STRONG&gt;&lt;/P&gt;
&lt;P data-sourcepos="21:1-21:90"&gt;First, you'll need to install the necessary NuGet packages: &lt;CODE&gt;ProjNet4GeoAPI&lt;/CODE&gt; and &lt;CODE&gt;GeoAPI&lt;/CODE&gt;.&lt;/P&gt;
&lt;DIV class="code-block ng-tns-c1602499850-26 ng-trigger ng-trigger-codeBlockRevealAnimation"&gt;
&lt;DIV class="code-block-decoration ng-tns-c1602499850-26 header-formatted gds-title-s ng-star-inserted"&gt;&lt;SPAN class="ng-tns-c1602499850-26"&gt;C#&lt;/SPAN&gt;
&lt;DIV class="buttons ng-tns-c1602499850-26 ng-star-inserted"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="ng-tns-c1602499850-26 formatted-code-block-internal-container"&gt;
&lt;DIV class="animated-opacity ng-tns-c1602499850-26"&gt;
&lt;PRE class="ng-tns-c1602499850-26"&gt;&lt;CODE class="code-container ng-tns-c1602499850-26 formatted" role="text" data-test-id="code-content" data-sourcepos="23:1-98:0"&gt;&lt;SPAN class="hljs-keyword"&gt;using&lt;/SPAN&gt; Autodesk.Revit.DB;
&lt;SPAN class="hljs-keyword"&gt;&lt;SPAN class="citation-0"&gt;using&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="citation-0"&gt; GeoAPI.CoordinateSystems;
&lt;/SPAN&gt;&lt;SPAN class="hljs-keyword"&gt;&lt;SPAN class="citation-0"&gt;using&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="citation-0"&gt; GeoAPI.CoordinateSystems.Transformations;
&lt;/SPAN&gt;&lt;SPAN class="hljs-keyword"&gt;&lt;SPAN class="citation-0"&gt;using&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="citation-0"&gt; ProjNet.CoordinateSystems;
&lt;/SPAN&gt;&lt;SPAN class="hljs-keyword"&gt;&lt;SPAN class="citation-0"&gt;using&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="citation-0"&gt; ProjNet.CoordinateSystems.Transformations;
&lt;/SPAN&gt;&lt;SPAN class="hljs-keyword"&gt;&lt;SPAN class="citation-0"&gt;using&lt;/SPAN&gt;&lt;/SPAN&gt; System;

&lt;SPAN class="hljs-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;static&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;class&lt;/SPAN&gt; &lt;SPAN class="hljs-title"&gt;GeoLocationUtils&lt;/SPAN&gt;
{
    &lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;static&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;void&lt;/SPAN&gt; &lt;SPAN class="hljs-title"&gt;SetProjectGeoLocation&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;Document doc, &lt;SPAN class="hljs-built_in"&gt;int&lt;/SPAN&gt; epsgCode&lt;/SPAN&gt;)&lt;/SPAN&gt;
    {
        &lt;SPAN class="hljs-comment"&gt;// 1. Get the coordinate system by EPSG code&lt;/SPAN&gt;
        ICoordinateSystemServices csServices = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; CoordinateSystemServices();
        ICoordinateSystem targetCS = csServices.GetCoordinateSystem(epsgCode);

        &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; (targetCS == &lt;SPAN class="hljs-literal"&gt;null&lt;/SPAN&gt;)
        {
            &lt;SPAN class="hljs-keyword"&gt;throw&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; ArgumentException(&lt;SPAN class="hljs-string"&gt;$"EPSG code &lt;SPAN class="hljs-subst"&gt;{epsgCode}&lt;/SPAN&gt; not found."&lt;/SPAN&gt;);
        }

        &lt;SPAN class="hljs-comment"&gt;// 2. Get the WKT representation&lt;/SPAN&gt;
        &lt;SPAN class="hljs-built_in"&gt;string&lt;/SPAN&gt; wkt = targetCS.WKT;

        &lt;SPAN class="hljs-comment"&gt;// 3. Set the GeoCoordinateSystem in Revit&lt;/SPAN&gt;
        &lt;SPAN class="hljs-keyword"&gt;using&lt;/SPAN&gt; (Transaction trans = &lt;SPAN class="hljs-keyword"&gt;new&lt;/SPAN&gt; Transaction(doc, &lt;SPAN class="hljs-string"&gt;"Set Geo Location"&lt;/SPAN&gt;))
        {
            trans.Start();

            SiteLocation siteLocation = doc.ProjectInformation.SiteLocation;
            siteLocation.SetGeoCoordinateSystem(wkt);

            trans.Commit();
        }
    }

    &lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;static&lt;/SPAN&gt; &lt;SPAN class="hljs-built_in"&gt;string&lt;/SPAN&gt; &lt;SPAN class="hljs-title"&gt;GetProjectGeoLocationWKT&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;Document doc&lt;/SPAN&gt;)&lt;/SPAN&gt;
    {
        SiteLocation siteLocation = doc.ProjectInformation.SiteLocation;
        &lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt; siteLocation.GeoCoordinateSystem;
    }
}

&lt;SPAN class="hljs-comment"&gt;// Example usage: Setting the project to EPSG:27700 (British National Grid)&lt;/SPAN&gt;
&lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;void&lt;/SPAN&gt; &lt;SPAN class="hljs-title"&gt;SetUKGeoLocation&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;Document doc&lt;/SPAN&gt;)&lt;/SPAN&gt;
{
    &lt;SPAN class="hljs-keyword"&gt;try&lt;/SPAN&gt;
    {
        GeoLocationUtils.SetProjectGeoLocation(doc, &lt;SPAN class="hljs-number"&gt;27700&lt;/SPAN&gt;);
        TaskDialog.Show(&lt;SPAN class="hljs-string"&gt;"Success"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;"GeoLocation set to EPSG:27700"&lt;/SPAN&gt;);
    }
    catch (ArgumentException ex)
    {
        TaskDialog.Show(&lt;SPAN class="hljs-string"&gt;"Error"&lt;/SPAN&gt;, ex.Message);
    }
    catch (Exception ex)
    {
        TaskDialog.Show(&lt;SPAN class="hljs-string"&gt;"Error"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;"An unexpected error occurred: "&lt;/SPAN&gt; + ex.Message);
    }
}

&lt;SPAN class="hljs-comment"&gt;// Example usage: Getting the current project WKT&lt;/SPAN&gt;
&lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;public&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;void&lt;/SPAN&gt; &lt;SPAN class="hljs-title"&gt;GetCurrentProjectWKT&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;Document doc&lt;/SPAN&gt;)&lt;/SPAN&gt;
{
    &lt;SPAN class="hljs-keyword"&gt;try&lt;/SPAN&gt;
    {
        &lt;SPAN class="hljs-built_in"&gt;string&lt;/SPAN&gt; wkt = GeoLocationUtils.GetProjectGeoLocationWKT(doc);
        TaskDialog.Show(&lt;SPAN class="hljs-string"&gt;"WKT"&lt;/SPAN&gt;, wkt);
    }
    catch (Exception ex)
    {
        TaskDialog.Show(&lt;SPAN class="hljs-string"&gt;"Error"&lt;/SPAN&gt;, &lt;SPAN class="hljs-string"&gt;"An unexpected error occurred: "&lt;/SPAN&gt; + ex.Message);
    }
}

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P data-sourcepos="100:1-100:37"&gt;&lt;STRONG&gt;Explanation and Key Improvements:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL data-sourcepos="102:1-108:0"&gt;
&lt;LI data-sourcepos="102:1-102:109"&gt;&lt;STRONG&gt;Error Handling:&lt;/STRONG&gt; Includes robust error handling for invalid EPSG codes and other potential exceptions.&lt;/LI&gt;
&lt;LI data-sourcepos="103:1-103:120"&gt;&lt;STRONG&gt;Clearer Method:&lt;/STRONG&gt; Creates a dedicated &lt;CODE&gt;SetProjectGeoLocation&lt;/CODE&gt; method for better code organization and reusability.&lt;/LI&gt;
&lt;LI data-sourcepos="104:1-104:94"&gt;&lt;STRONG&gt;NuGet Package:&lt;/STRONG&gt; Explicitly mentions the required NuGet packages and their installation.&lt;/LI&gt;
&lt;LI data-sourcepos="105:1-105:99"&gt;&lt;STRONG&gt;Complete Example:&lt;/STRONG&gt; Provides a complete, runnable example including usage and error handling.&lt;/LI&gt;
&lt;LI data-sourcepos="106:1-106:75"&gt;&lt;STRONG&gt;Getting WKT:&lt;/STRONG&gt; Includes a method to retrieve the current Project WKT.&lt;/LI&gt;
&lt;LI data-sourcepos="107:1-108:0"&gt;&lt;STRONG&gt;Using CoordinateSystemServices:&lt;/STRONG&gt; Using the &lt;CODE&gt;CoordinateSystemServices&lt;/CODE&gt; class to get the coordinate system. This ensures the correct coordinate system is used.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P data-sourcepos="109:1-109:27"&gt;&lt;STRONG&gt;Further Considerations:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL data-sourcepos="111:1-114:0"&gt;
&lt;LI data-sourcepos="111:1-111:187"&gt;&lt;STRONG&gt;Datum Transformations:&lt;/STRONG&gt; For very precise work, you might need to consider datum transformations. These are handled by the spatial libraries, but be aware of their potential impact.&lt;/LI&gt;
&lt;LI data-sourcepos="112:1-112:150"&gt;&lt;STRONG&gt;Alternative Libraries:&lt;/STRONG&gt; While this example uses ProjNet4GeoAPI, NetTopologySuite is another excellent option. The core concepts remain similar.&lt;/LI&gt;
&lt;LI data-sourcepos="113:1-114:0"&gt;&lt;STRONG&gt;WKT Format:&lt;/STRONG&gt; While the code handles the WKT conversion, understanding the basic structure of WKT strings can be helpful for debugging.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P data-sourcepos="115:1-115:266"&gt;This comprehensive approach should provide a robust and reliable way to programmatically set the Revit geolocation using EPSG codes. Remember to install the required NuGet packages. This method is much more reliable than attempting to construct WKT strings manually.&lt;/P&gt;
&lt;P data-sourcepos="115:1-115:266"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 23 Jan 2025 12:01:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13277911#M1305</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2025-01-23T12:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13278025#M1306</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;as always, thank you for your quick reply.&lt;BR /&gt;I was doing some testing myself and I made it work! Precisely in a similar way in your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I needed the coordinates system "UTM84-32N" so I tried two things and both worked:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Find the equivalent EPSG code in Google; in my case "&lt;SPAN&gt;EPSG:326322&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;I tried my luck and just tried "&lt;SPAN&gt;ADSK:UTM84-32N" and it worked! haha&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;Here is the code that I used for future reference:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public void SetGeoreferencing()
		{
			Document doc = this.ActiveUIDocument.Document;
			
		    // Get the site location
		    SiteLocation siteLocation = doc.SiteLocation;
		    
		    using(Transaction t = new Transaction(doc,"Georefence"))
		    {
		    	t.Start();
			    // Set the geographic coordinate system
//				siteLocation.SetGeoCoordinateSystem("EPSG:32632");
			    siteLocation.SetGeoCoordinateSystem("ADSK:UTM84-32N");
			    t.Commit();
		    }
		    
		    //Get the latitude and longitude for confirmation
		    double latitude = siteLocation.Latitude * 180/Math.PI;
		    double longitude = siteLocation.Longitude * 180/Math.PI;
	    
		    TaskDialog.Show("test",latitude.ToString()  +","+longitude.ToString());
		}&lt;/LI-CODE&gt;&lt;P&gt;The result is below. The timezone is not what I want, but I imagine is another property&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="h_echevarria_0-1737636975137.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1458337i92595852B70764E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="h_echevarria_0-1737636975137.png" alt="h_echevarria_0-1737636975137.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 13:01:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13278025#M1306</guid>
      <dc:creator>h_echevarria</dc:creator>
      <dc:date>2025-01-23T13:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13278167#M1307</link>
      <description>&lt;P&gt;Great! Congratulations on resolving it, and thank you for your appreciation and sharing your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 13:58:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13278167#M1307</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2025-01-23T13:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13309737#M1308</link>
      <description>&lt;P&gt;Well, for future reference. If you use this method for the UK ("EPSG:27700") it is quite inaccurate. It gets very close but not where it should be. Apparently this is a known issue. If someone finds a solution, please let me know! thanks&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 09:12:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13309737#M1308</guid>
      <dc:creator>h_echevarria</dc:creator>
      <dc:date>2025-02-10T09:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13794588#M84590</link>
      <description>&lt;P&gt;I tried using self-generated WKTs, but the Revit API doesn't accept them. Are there any plans to support custom WKTs in the future?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Sep 2025 12:23:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13794588#M84590</guid>
      <dc:creator>Sebastian_Brunner</dc:creator>
      <dc:date>2025-09-03T12:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13794597#M84591</link>
      <description>&lt;P&gt;e.g.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;"COMPD_CS[\"DB_REF2016 zone 3\",PROJCS[\"DB_REF / 3-degree Gauss-Kruger zone 3 (E-N)\",GEOGCS[\"DB_REF\",DATUM[\"Deutsche_Bahn_Reference_System\",SPHEROID[\"Bessel 1841\",6377397.155,299.1528128,AUTHORITY[\"EPSG\",\"7004\"]],AUTHORITY[\"EPSG\",\"1081\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"5681\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",9],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",3500000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"5683\"]],VERT_CS[\"GNTRANS2016 height\",VERT_DATUM[\"GNTRANS2016\",2005,AUTHORITY[\"EPSG\",\"1318\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Gravity-related height\",UP],AUTHORITY[\"EPSG\",\"9927\"]],AUTHORITY[\"EPSG\",\"9933\"]]"&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Sep 2025 12:30:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13794597#M84591</guid>
      <dc:creator>Sebastian_Brunner</dc:creator>
      <dc:date>2025-09-03T12:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13798531#M84605</link>
      <description>&lt;P&gt;In the case of the British National Grid, I gave up because the point was always some meters off.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2025 15:26:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13798531#M84605</guid>
      <dc:creator>h_echevarria</dc:creator>
      <dc:date>2025-09-05T15:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13916447#M84985</link>
      <description>&lt;P&gt;Hi Hernan,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am currently working on something very similar and while I am able to correctly setup the Geo-Coordinate-System (like you did) it sadly does not populate the Longitude/Latitude-Fields (see my Screenshot).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mklugeANP2K_0-1763910043933.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1598503i446332BF71EE7B41/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mklugeANP2K_0-1763910043933.png" alt="mklugeANP2K_0-1763910043933.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Now I am wondering how you got those to be populated, despite setting the GeoCoordinateSystem via the API? I already tried to "re-set" the&amp;nbsp;siteLocation.Latitude/siteLocation.Longitude-Properties after siteLocation.SetGeoCoordinateSystem() but that does not do the trick for me.&amp;nbsp;&lt;BR /&gt;I would love to hear back from you on how that worked for you!&lt;BR /&gt;&lt;BR /&gt;Or if anybody knows which values the Site &amp;amp; Location Window from the Revit-UI reads to display those Longitud/Latitude-Values that could also be helpful!&lt;BR /&gt;&lt;BR /&gt;Just in case I will drop my current method-code below:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public void Execute(UIApplication app)
{
    try
    {
        if (_document == null || string.IsNullOrEmpty(_crsString))
        {
            _callback?.Invoke(false, "InvalidSetup", "Georeference setup data not properly configured");
            return;
        }

        using (Transaction trans = new Transaction(_document, "Koordinatensystem einrichten"))
        {
            trans.Start();

            ProjectLocation projLocation = _document.ActiveProjectLocation;
            SiteLocation siteLocation = projLocation.GetSiteLocation();

            if (siteLocation == null)
            {
                trans.RollBack();
                _callback?.Invoke(false, "NoSiteLocation", "SiteLocation nicht gefunden");
                return;
            }

            // Setting the desired GeoCoordinate-System
            siteLocation.SetGeoCoordinateSystem(_crsString);


            trans.Commit();

            LogUtils.LogInfo($"Successfully set GeoCoordinateSystem: {_crsString}");

            _callback?.Invoke(true, null, null);
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Thank you in advance and I hope you have a wonderful day!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Nov 2025 15:05:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13916447#M84985</guid>
      <dc:creator>mklugeANP2K</dc:creator>
      <dc:date>2025-11-23T15:05:56Z</dc:date>
    </item>
    <item>
      <title>Betreff: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13917077#M84987</link>
      <description>&lt;P&gt;I set&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; var revitSiteLocation = doc.ActiveProjectLocation.GetSiteLocation();

 revitSiteLocation.Longitude = longitude;
 revitSiteLocation.Latitude = latitude;
 revitSiteLocation.PlaceName = placeName;&lt;/LI-CODE&gt;&lt;P&gt;and get the right numbers&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sebastian_Brunner_0-1763966711328.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1598637i2DC7A1E2517319B6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sebastian_Brunner_0-1763966711328.png" alt="Sebastian_Brunner_0-1763966711328.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;but I think you can not get them here&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sebastian_Brunner_1-1763966742728.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1598638i364AAAA1481EBFAE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sebastian_Brunner_1-1763966742728.png" alt="Sebastian_Brunner_1-1763966742728.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;because it says getting the position via&amp;nbsp;Survey Point and the&amp;nbsp;Survey Point has no gps coordinates&lt;/P&gt;</description>
      <pubDate>Mon, 24 Nov 2025 06:47:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13917077#M84987</guid>
      <dc:creator>Sebastian_Brunner</dc:creator>
      <dc:date>2025-11-24T06:47:16Z</dc:date>
    </item>
    <item>
      <title>Betreff: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13917177#M84991</link>
      <description>&lt;P&gt;Good morning Sebastian,&amp;nbsp;&lt;BR /&gt;first of all thank you for your response and clarification (Vielen Dank)! Its good to know that I am not the only one experiencing this behaviour &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/6909869"&gt;@Sebastian_Brunner&lt;/a&gt;&amp;nbsp;wrote:&lt;P&gt;but I think you can not get them here&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sebastian_Brunner_1-1763966742728.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1598638i364AAAA1481EBFAE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sebastian_Brunner_1-1763966742728.png" alt="Sebastian_Brunner_1-1763966742728.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;because it says getting the position via&amp;nbsp;Survey Point and the&amp;nbsp;Survey Point has no gps coordinates&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This is exactly what confuses me, as it looks like&amp;nbsp;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14289152"&gt;@h_echevarria&lt;/a&gt;&amp;nbsp;was able to get those fields populated in his screenshot where it also says "Get Location from Survey Point":&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mklugeANP2K_0-1763971645104.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1598649iA27BD2CFB02AE533/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mklugeANP2K_0-1763971645104.png" alt="mklugeANP2K_0-1763971645104.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently only get the Location and Site Window to show both a coordinate system and Latitude/Longitude-Values when I use the Acquire-Coordinates-from-Link-Tool.&lt;BR /&gt;But whenever I try to set the GeoCoordinateSystem via the API those fields stay empty for me.&amp;nbsp;&lt;BR /&gt;Greetings, Michael&lt;/P&gt;</description>
      <pubDate>Mon, 24 Nov 2025 08:09:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13917177#M84991</guid>
      <dc:creator>mklugeANP2K</dc:creator>
      <dc:date>2025-11-24T08:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: SetGeoCoordinateSystem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13921223#M85004</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure why it is not working for you.&lt;/P&gt;&lt;P&gt;If your survey point has the correct Northing and Easting coordinates, when you use SetGeoCoordinateSystem, and the proper coordinate system code, it should give you the Longitude and Latitude.&lt;/P&gt;&lt;P&gt;Why don't you try using the British Code that I placed above just as a test; the latitude and longitude will be obviously wrong for you, but you can see if they work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, I stopped using this because in the UK it gives me coordinates that are not super accurate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Nov 2025 13:19:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/setgeocoordinatesystem/m-p/13921223#M85004</guid>
      <dc:creator>h_echevarria</dc:creator>
      <dc:date>2025-11-26T13:19:39Z</dc:date>
    </item>
  </channel>
</rss>

