<?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 Getting/modifying object coordinates in AutoCAD Map 3D Developer Forum</title>
    <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/getting-modifying-object-coordinates/m-p/9852697#M306</link>
    <description>&lt;P&gt;As part of a utility planning project I need to place a large number of objects on to the map at certain geo-coordinates. I would like to do that by using the C# or VB.Net API of AutoCad Map 2020 but found no way to access/define the coordinate data of an object. On the other hand the coordinates can be easily checked/modified within the AutoCad Map 2020 application under the Modify/Properties menu. Here it is possible to change the x,y coordinate values within the pop-up window's&amp;nbsp; 'Geometry' table and the object 'moves' to the new location.&amp;nbsp; That is exactly the functionality that I can not find within the .Net API. The following VBA code gives access to the ODTables of an object but the coordinates are not among them:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; tables &lt;SPAN class="hljs-keyword"&gt;As&lt;/SPAN&gt; ObjectData.Tables
tables = activeProj.ODTables&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; table &lt;SPAN class="hljs-keyword"&gt;As&lt;/SPAN&gt; ObjectData.Table
table = tables.Item(FieldName)&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; fieldDefs &lt;SPAN class="hljs-keyword"&gt;As&lt;/SPAN&gt; ObjectData.FieldDefinitions = table.FieldDefinitions
&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; recs &lt;SPAN class="hljs-keyword"&gt;As&lt;/SPAN&gt; ObjectData.Records
recs = table.GetObjectTableRecords(&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;, BlckID, Constants.OpenMode.OpenForRead, &lt;SPAN class="hljs-literal"&gt;True&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for any hints about accessing the coordinates data.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 07 Nov 2020 15:56:09 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-11-07T15:56:09Z</dc:date>
    <item>
      <title>Getting/modifying object coordinates</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/getting-modifying-object-coordinates/m-p/9852697#M306</link>
      <description>&lt;P&gt;As part of a utility planning project I need to place a large number of objects on to the map at certain geo-coordinates. I would like to do that by using the C# or VB.Net API of AutoCad Map 2020 but found no way to access/define the coordinate data of an object. On the other hand the coordinates can be easily checked/modified within the AutoCad Map 2020 application under the Modify/Properties menu. Here it is possible to change the x,y coordinate values within the pop-up window's&amp;nbsp; 'Geometry' table and the object 'moves' to the new location.&amp;nbsp; That is exactly the functionality that I can not find within the .Net API. The following VBA code gives access to the ODTables of an object but the coordinates are not among them:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; tables &lt;SPAN class="hljs-keyword"&gt;As&lt;/SPAN&gt; ObjectData.Tables
tables = activeProj.ODTables&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; table &lt;SPAN class="hljs-keyword"&gt;As&lt;/SPAN&gt; ObjectData.Table
table = tables.Item(FieldName)&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; fieldDefs &lt;SPAN class="hljs-keyword"&gt;As&lt;/SPAN&gt; ObjectData.FieldDefinitions = table.FieldDefinitions
&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; recs &lt;SPAN class="hljs-keyword"&gt;As&lt;/SPAN&gt; ObjectData.Records
recs = table.GetObjectTableRecords(&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;, BlckID, Constants.OpenMode.OpenForRead, &lt;SPAN class="hljs-literal"&gt;True&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for any hints about accessing the coordinates data.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Nov 2020 15:56:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/getting-modifying-object-coordinates/m-p/9852697#M306</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-07T15:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Getting/modifying object coordinates</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/getting-modifying-object-coordinates/m-p/9854016#M307</link>
      <description>&lt;P&gt;I am not sure I understand what you really want to do. What do you mean by "geo-coordinate"? if the said "large number of objects are already in drawing, the coordinate would be X/East and Y/North, (regardless what projected map coordinate system is assigned to the drawing, like UTM83-xx...), right? So, I assume you want to get/modify the coordinates/geometries of entities according to your business requirements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since all entities you see in AutoCAD editor are just visual presentation of geometries (with other properties, like layer, color...), if you can access entity via API (be it LISP, VBA/COM, or .NET API), you can have access to all geometric information of an entity, and modify some of them. The geometric information has nothing to do with ObjectData (well, for some business reason, one could use ObjectData to store redundant entity geometry, of course).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The convenience provided by Property window, where one can change geometric data of an selected entity, is built on a set of APIs, on which AutoCAD .NET API is based. So, certainly you can change a line's length by changing one of its EndPoint, or you move move it by given displacement, rather easily. By the way, these basic process of using API is from plain AutoCAD API and apply to all AutoCAD verticals. AutoCAD Map add its on API on top of AutoCAD API, dealing map specific operations, such as ObjectData/Classification, map query....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Quick .NET API code of getting/modifying a line (assume you have code to asked user to selected a line, and selected 2 points)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Public void ModifyLine(ObjectId lineId, Point3d startPt, Point3d endPt)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; using (var tran = lineId.Database.TransactionManager.StartTransaction())&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var line = (Line)tran.GetObject(lineId, OpenMode.ForWrite);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // access Line's geometries&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Debug.WriteLine($"Start point =&amp;gt; {line.StartPoint.ToString()}"&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Debug.WriteLine($"End point =&amp;gt; {line.EndPoint.ToString()}"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// modify Line's geometries&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; line.StartPoint = startPoint;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; line.EndPoint = endPoint;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tran.Commit()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, you can do similar thing with LISP, or VBA.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2020 16:11:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/getting-modifying-object-coordinates/m-p/9854016#M307</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2020-11-08T16:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Getting/modifying object coordinates</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/getting-modifying-object-coordinates/m-p/9886799#M308</link>
      <description>&lt;P&gt;Many thanks for your reply. The issue I have raised can be solved on that basis.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Nov 2020 10:19:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/getting-modifying-object-coordinates/m-p/9886799#M308</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-11-22T10:19:47Z</dc:date>
    </item>
  </channel>
</rss>

