<?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 Calculating the angle between UCS and WCS in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/calculating-the-angle-between-ucs-and-wcs/m-p/3045758#M60640</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A "noob" question im afriad regarding converting angles between co-ordinate systems in AutoCAD .NET. Im struggling to find much on the subject and would appriciate some help or a point in the right direction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Problem:&lt;/P&gt;&lt;P&gt;Im creating my first little utility to form selected block attibute references into a nice neat list. The current version takes a selection of blocks and a list insert location and then moves the attribute references to the location and rotates them to WCS angle of 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I now want to expand the program to make it a little more flexible and allow you to form the list parrallel to the currently selected UCS x axis (the i.e. and angle of 0 in relation to current ucs's).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have managed bumble my way through and transform the attribute positions correctly to form a list relative to the current UCS but am strugling on how to work out in code what the equivlanent WCS angle value would be.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have done some calcs using .net framework to calculate an angle between two vectors (see code extract below). But this introduces a small error into the angles (i.e. if my ucs is set rotated 45 degrees around the zed and i use the below maths, the resulatant angle is 45.0000002 when read in acad afterwards).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Matrix3d ucsCur = ed.CurrentUserCoordinateSystem;﻿&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;CoordinateSystem3d cs = ucsCur.CoordinateSystem3d;﻿&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;// the below seems to work by calugulating the angle between two vetrex using .net maths class but this introduce a small accuracy error﻿﻿. Is there a better way?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Double rotAngle = Math.Acos((1 * cs.Xaxis.X) + (0 * cs.Xaxis.Y) + (0 * cs.Xaxis.Z));﻿&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;//set the attribute reference rotation to the calculated WCS radian rotation value "rotAngle"&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;attRef.Rotation = rotAngle;﻿&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im sure there is a better way built into the managed autocad wrapper using a tranform matix and the ucs vertex information but dont really know how to go about it. Any ideas? Also, if anyone know of any links explaining how to work with the UCS in .net they would be appriciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Richard.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jun 2011 11:27:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-06-03T11:27:18Z</dc:date>
    <item>
      <title>Calculating the angle between UCS and WCS</title>
      <link>https://forums.autodesk.com/t5/net-forum/calculating-the-angle-between-ucs-and-wcs/m-p/3045758#M60640</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A "noob" question im afriad regarding converting angles between co-ordinate systems in AutoCAD .NET. Im struggling to find much on the subject and would appriciate some help or a point in the right direction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Problem:&lt;/P&gt;&lt;P&gt;Im creating my first little utility to form selected block attibute references into a nice neat list. The current version takes a selection of blocks and a list insert location and then moves the attribute references to the location and rotates them to WCS angle of 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I now want to expand the program to make it a little more flexible and allow you to form the list parrallel to the currently selected UCS x axis (the i.e. and angle of 0 in relation to current ucs's).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have managed bumble my way through and transform the attribute positions correctly to form a list relative to the current UCS but am strugling on how to work out in code what the equivlanent WCS angle value would be.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have done some calcs using .net framework to calculate an angle between two vectors (see code extract below). But this introduces a small error into the angles (i.e. if my ucs is set rotated 45 degrees around the zed and i use the below maths, the resulatant angle is 45.0000002 when read in acad afterwards).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Matrix3d ucsCur = ed.CurrentUserCoordinateSystem;﻿&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;CoordinateSystem3d cs = ucsCur.CoordinateSystem3d;﻿&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;// the below seems to work by calugulating the angle between two vetrex using .net maths class but this introduce a small accuracy error﻿﻿. Is there a better way?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Double rotAngle = Math.Acos((1 * cs.Xaxis.X) + (0 * cs.Xaxis.Y) + (0 * cs.Xaxis.Z));﻿&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;//set the attribute reference rotation to the calculated WCS radian rotation value "rotAngle"&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;attRef.Rotation = rotAngle;﻿&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im sure there is a better way built into the managed autocad wrapper using a tranform matix and the ucs vertex information but dont really know how to go about it. Any ideas? Also, if anyone know of any links explaining how to work with the UCS in .net they would be appriciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Richard.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2011 11:27:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/calculating-the-angle-between-ucs-and-wcs/m-p/3045758#M60640</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-03T11:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the angle between UCS and WCS</title>
      <link>https://forums.autodesk.com/t5/net-forum/calculating-the-angle-between-ucs-and-wcs/m-p/3046452#M60641</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cs.Xaxis.AngleOnPlane(&lt;FONT color="#0000ff" face="Courier New"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;New&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Courier New"&gt;&lt;FONT color="#2b91af" face="Courier New"&gt;Plane&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;(&lt;/FONT&gt;&lt;FONT color="#2b91af" face="Courier New"&gt;&lt;FONT color="#2b91af" face="Courier New"&gt;Point3d&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;.Origin, &lt;/FONT&gt;&lt;FONT color="#2b91af" face="Courier New"&gt;&lt;FONT color="#2b91af" face="Courier New"&gt;Vector3d&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New"&gt;.XAxis))&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2011 18:08:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/calculating-the-angle-between-ucs-and-wcs/m-p/3046452#M60641</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2011-06-03T18:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the angle between UCS and WCS</title>
      <link>https://forums.autodesk.com/t5/net-forum/calculating-the-angle-between-ucs-and-wcs/m-p/3047028#M60642</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That seems to work a treat. I had to make one small change which was to specify "vector3d.zaxis" in the plane constructor parameters rather than "vector3d.xaxis" as shown below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Double rotAngle = cs.Xaxis.AngleOnPlane(new Plane(Point3d.Origin, Vector3d.ZAxis));﻿&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know for sure (thanks to lack of intellisense summary information for the autocad .net classes and not having the AutoCAD.net developer guide to hand atm), but i assume vector3d in the plane contructor is to provide the facing/ normal direction of the plane.﻿ So to get a plane in the xy orientation you have to pass a Z vector.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jun 2011 12:54:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/calculating-the-angle-between-ucs-and-wcs/m-p/3047028#M60642</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-06-04T12:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the angle between UCS and WCS</title>
      <link>https://forums.autodesk.com/t5/net-forum/calculating-the-angle-between-ucs-and-wcs/m-p/3047370#M60643</link>
      <description>&lt;P&gt;Sorry, my post should have said ZAxis in the constructor...&amp;nbsp; Not sure how that happened really, I copied and pasted that from working code.&amp;nbsp; And that is correct the constructor is looking for the Normal vector.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jun 2011 19:53:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/calculating-the-angle-between-ucs-and-wcs/m-p/3047370#M60643</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2011-06-05T19:53:52Z</dc:date>
    </item>
  </channel>
</rss>

