<?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 the coordinates of an entity base upon its UCS as a base point. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/getting-the-coordinates-of-an-entity-base-upon-its-ucs-as-a-base/m-p/7271185#M30335</link>
    <description>&lt;P&gt;I am trying to move a UCS to a particular point and then get the coordinates of an Entity ,in this case a circle, based upon the UCS I just moved as its base point. The results of the coordinates obtained from code are incorrect (X3.0,Y5.5,Z0) which makes no sense. They should be (X2.5,Y0.0,Z0.0). after my code runs I can check the coordinates manually in AutoCad and the are correct. Not sure what the problem is.Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    private static void UcsBaseCoords(Circle circle, Point3d newBasePoint)
    {
        var acDoc = Active.Document;

        CoordinateSystem3d coordSystem = new CoordinateSystem3d(newBasePoint, new Vector3d(0, -1, 0),new Vector3d(1, 0, 0));

        CoordinateSystem3d cosy = acDoc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d;

        var ecs = Matrix3d.AlignCoordinateSystem(cosy.Origin, cosy.Xaxis, cosy.Yaxis, cosy.Zaxis, coordSystem.Origin, coordSystem.Xaxis, coordSystem.Yaxis, coordSystem.Zaxis);

        acDoc.Editor.CurrentUserCoordinateSystem = ecs;

        acDoc.Editor.UpdateTiledViewportsInDatabase();

        var coodrsBasedOnUcs = circle.Center.TransformBy(ecs);
        acDoc.Editor.WriteMessage(String.Format("X{0}, Y{1}, Z{2}", coodrsBasedOnUcs.X, coodrsBasedOnUcs.Y, coodrsBasedOnUcs.Z));
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is after my program runs and it is correct. My UCS has been moved and If I check the circle's coordinates they are correct.(X2.5,Y0.0,Z0.0)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="p5.png" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/385050i77EC6C5E30A0F98C/image-size/large?v=v2&amp;amp;px=999" role="button" title="p5.png" alt="p5.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my dwg before I run my program.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="p3.png" style="width: 700px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/385047i38E1DEB62B64FAEE/image-size/large?v=v2&amp;amp;px=999" role="button" title="p3.png" alt="p3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Aug 2017 13:44:03 GMT</pubDate>
    <dc:creator>gotMorris</dc:creator>
    <dc:date>2017-08-02T13:44:03Z</dc:date>
    <item>
      <title>Getting the coordinates of an entity base upon its UCS as a base point.</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-the-coordinates-of-an-entity-base-upon-its-ucs-as-a-base/m-p/7271185#M30335</link>
      <description>&lt;P&gt;I am trying to move a UCS to a particular point and then get the coordinates of an Entity ,in this case a circle, based upon the UCS I just moved as its base point. The results of the coordinates obtained from code are incorrect (X3.0,Y5.5,Z0) which makes no sense. They should be (X2.5,Y0.0,Z0.0). after my code runs I can check the coordinates manually in AutoCad and the are correct. Not sure what the problem is.Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    private static void UcsBaseCoords(Circle circle, Point3d newBasePoint)
    {
        var acDoc = Active.Document;

        CoordinateSystem3d coordSystem = new CoordinateSystem3d(newBasePoint, new Vector3d(0, -1, 0),new Vector3d(1, 0, 0));

        CoordinateSystem3d cosy = acDoc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d;

        var ecs = Matrix3d.AlignCoordinateSystem(cosy.Origin, cosy.Xaxis, cosy.Yaxis, cosy.Zaxis, coordSystem.Origin, coordSystem.Xaxis, coordSystem.Yaxis, coordSystem.Zaxis);

        acDoc.Editor.CurrentUserCoordinateSystem = ecs;

        acDoc.Editor.UpdateTiledViewportsInDatabase();

        var coodrsBasedOnUcs = circle.Center.TransformBy(ecs);
        acDoc.Editor.WriteMessage(String.Format("X{0}, Y{1}, Z{2}", coodrsBasedOnUcs.X, coodrsBasedOnUcs.Y, coodrsBasedOnUcs.Z));
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is after my program runs and it is correct. My UCS has been moved and If I check the circle's coordinates they are correct.(X2.5,Y0.0,Z0.0)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="p5.png" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/385050i77EC6C5E30A0F98C/image-size/large?v=v2&amp;amp;px=999" role="button" title="p5.png" alt="p5.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my dwg before I run my program.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="p3.png" style="width: 700px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/385047i38E1DEB62B64FAEE/image-size/large?v=v2&amp;amp;px=999" role="button" title="p3.png" alt="p3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 13:44:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-the-coordinates-of-an-entity-base-upon-its-ucs-as-a-base/m-p/7271185#M30335</guid>
      <dc:creator>gotMorris</dc:creator>
      <dc:date>2017-08-02T13:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the coordinates of an entity base upon its UCS as a base point.</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-the-coordinates-of-an-entity-base-upon-its-ucs-as-a-base/m-p/7272356#M30336</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous.mymail wrote:&lt;BR /&gt;&lt;P&gt;I am trying to move a UCS to a particular point and then get the coordinates of an Entity ,in this case a circle, based upon the UCS I just moved as its base point. The results of the coordinates obtained from code are incorrect (X3.0,Y5.5,Z0) which makes no sense. They should be (X2.5,Y0.0,Z0.0). after my code runs I can check the coordinates manually in AutoCad and the are correct. Not sure what the problem is.Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    private static void UcsBaseCoords(Circle circle, Point3d newBasePoint)
    {
        var acDoc = Active.Document;

        CoordinateSystem3d coordSystem = new CoordinateSystem3d(newBasePoint, new Vector3d(0, -1, 0),new Vector3d(1, 0, 0));

        CoordinateSystem3d cosy = acDoc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d;

        var ecs = Matrix3d.AlignCoordinateSystem(cosy.Origin, cosy.Xaxis, cosy.Yaxis, cosy.Zaxis, coordSystem.Origin, coordSystem.Xaxis, coordSystem.Yaxis, coordSystem.Zaxis);

        acDoc.Editor.CurrentUserCoordinateSystem = ecs;

        acDoc.Editor.UpdateTiledViewportsInDatabase();

        var coodrsBasedOnUcs = circle.Center.TransformBy(ecs);
        acDoc.Editor.WriteMessage(String.Format("X{0}, Y{1}, Z{2}", coodrsBasedOnUcs.X, coodrsBasedOnUcs.Y, coodrsBasedOnUcs.Z));
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To go from WCS to Current UCS, you use the inversion of the current UCS matrix, however your code as written will not work unless the current UCS is the WCS. To get the transformation matrix from the WCS to a UCS defined by a CoordinateSystem3d, you use Matrix3d.Identity.CoordinateSystem3d as the 'from' coordinate system in the call to AlignCoordinateSystem():&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT color="#999999"&gt;    private static void UcsBaseCoords(Circle circle, Point3d newBasePoint)
    {
        var acDoc = Active.Document;

        CoordinateSystem3d coordSystem = new CoordinateSystem3d(newBasePoint, new Vector3d(0, -1, 0),new Vector3d(1, 0, 0));

&lt;FONT color="#FF0000"&gt;        CoordinateSystem3d cosy = Matrix3d.Identity.CoordinateSystem3d;&lt;/FONT&gt;
        var ecs = Matrix3d.AlignCoordinateSystem(cosy.Origin, cosy.Xaxis, cosy.Yaxis, cosy.Zaxis, coordSystem.Origin, coordSystem.Xaxis, coordSystem.Yaxis, coordSystem.Zaxis);

        acDoc.Editor.CurrentUserCoordinateSystem = ecs;

        acDoc.Editor.UpdateTiledViewportsInDatabase();&lt;BR /&gt;&lt;/FONT&gt;
        &lt;FONT color="#FF0000"&gt;var coodrsBasedOnUcs = circle.Center.TransformBy(ecs.Inverse());&lt;BR /&gt;&lt;/FONT&gt;
&lt;FONT color="#999999"&gt;        acDoc.Editor.WriteMessage(String.Format("X{0}, Y{1}, Z{2}", coodrsBasedOnUcs.X, coodrsBasedOnUcs.Y, coodrsBasedOnUcs.Z));&lt;/FONT&gt;    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 19:40:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-the-coordinates-of-an-entity-base-upon-its-ucs-as-a-base/m-p/7272356#M30336</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-08-02T19:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the coordinates of an entity base upon its UCS as a base point.</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-the-coordinates-of-an-entity-base-upon-its-ucs-as-a-base/m-p/7272381#M30337</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        private static void UcsBaseCoords(Circle circle, Point3d newBasePoint)
        {
            var acDoc = Active.Document;

            CoordinateSystem3d coordSystem = new CoordinateSystem3d(newBasePoint, new Vector3d(0, -1, 0), new Vector3d(1, 0, 0));

            CoordinateSystem3d cosy = acDoc.Editor.CurrentUserCoordinateSystem.CoordinateSystem3d;

            var ecs = Matrix3d.AlignCoordinateSystem(
                &lt;FONT color="#FF0000"&gt;Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis,&lt;/FONT&gt; 
                coordSystem.Origin, coordSystem.Xaxis, coordSystem.Yaxis, coordSystem.Zaxis);

            acDoc.Editor.CurrentUserCoordinateSystem = ecs;

            acDoc.Editor.UpdateTiledViewportsInDatabase();

            &lt;FONT color="#FF0000"&gt;var coodrsBasedOnUcs = circle.Center.TransformBy(ecs.Inverse());&lt;/FONT&gt;
            acDoc.Editor.WriteMessage(String.Format("X{0}, Y{1}, Z{2}", coodrsBasedOnUcs.X, coodrsBasedOnUcs.Y, coodrsBasedOnUcs.Z));
        }&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Aug 2017 19:35:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-the-coordinates-of-an-entity-base-upon-its-ucs-as-a-base/m-p/7272381#M30337</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-08-02T19:35:13Z</dc:date>
    </item>
  </channel>
</rss>

