<?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: AngleFromXAxis in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7171248#M7944</link>
    <description>&lt;P&gt;What data type is assigned to the blockLocation variable?&amp;nbsp; If assigned as a Double, there is no need to use CDbl which converts the value to a double.&amp;nbsp; Logically that alone shouldn't be a problem though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you use the Debug.Print statement in your code to output the current values of the blockLocation variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Debug.Print blockLocation(0)&lt;BR /&gt;&amp;nbsp; Debug.Print blockLocation(1)&lt;BR /&gt;&amp;nbsp; Debug.Print blockLocation(2)&lt;BR /&gt;&amp;nbsp; Debug.Print blockLocation(3)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output will go to the Immediate window in the VBA IDE upon execution during your program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you using a custom UCS by chance as well?&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2017 15:15:42 GMT</pubDate>
    <dc:creator>ambrosl</dc:creator>
    <dc:date>2017-06-22T15:15:42Z</dc:date>
    <item>
      <title>AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7166385#M7940</link>
      <description>&lt;P&gt;Can someone please explain to me why this works:&lt;/P&gt;&lt;PRE&gt;Sub Example_AngleFromXAxis()
    ' This example finds the angle, in radians, between the X axis
    ' and a line defined by two points.
    
    Dim pt1(0 To 2) As Double
    Dim pt2(0 To 2) As Double
    Dim retAngle As Double
    
    pt1(0) = 256833.405419725: pt1(1) = 5928142.14654379: pt1(2) = 0
    pt2(0) = 256890.630751811: pt2(1) = 5928014.31962269: pt2(2) = 0
    
    ' Return the angle
    retAngle = ThisDrawing.Utility.AngleFromXAxis(pt1, pt2)
    
    ' Create the line for a visual reference
    Dim lineObj As AcadLine
    Set lineObj = ThisDrawing.ModelSpace.AddLine(pt1, pt2)
    ZoomAll
    
    ' Display the angle found
    MsgBox "The angle in radians between the X axis and the line is " &amp;amp; retAngle, , "AngleFromXAxis Example"
    
End Sub&lt;/PRE&gt;&lt;P&gt;But, when those same coordinates are passed from another array is doesn't work??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;..........
pt1(0) = CDbl(blockLocation(0)): pt1(1) = CDbl(blockLocation(1)): pt1(2) = 0
pt2(0) = CDbl(blockLocation(2)): pt2(1) = CDbl(blockLocation(3)): pt2(2) = 0
retAngle = acadDoc.Utility.AngleFromXAxis(pt1, pt2)
..........&lt;/PRE&gt;&lt;P&gt;??&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 23:43:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7166385#M7940</guid>
      <dc:creator>ksd</dc:creator>
      <dc:date>2017-06-20T23:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7168037#M7941</link>
      <description>&lt;P&gt;As I explained at augi, you need to show how blockLocation is getting assigned. Its possible that all its values are empty if its not getting set properly.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 14:59:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7168037#M7941</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2017-06-21T14:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7169625#M7942</link>
      <description>&lt;P&gt;Hi thanks for the replies,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to avoid posting the whole code (for IP and glut reasons) but basically there is code that looks for a text in a block, when it find the right text it loads the coordinates into the blockLocation array&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; coords = ss.InsertionPoint
 blockLocation(0) = coords(0)
 blockLocation(1) = coords(1)&lt;/PRE&gt;&lt;P&gt;It then looks for a second set of text and loads the coordinates of that block the same way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; coords = ss.InsertionPoint
 blockLocation(2) = coords(0)
 blockLocation(3) = coords(1)&lt;/PRE&gt;&lt;P&gt;I have got the code to show me (in a msgbox) what the blockLocation() array has in it right before it throws it at the AngleFromXAxis, and the coordinates look fine. I used the coordinates from the message box to manually set the pt1() and pt2() in the working example, but they will not work when they're passed from the blockLocation array...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's no doubt something really simple I'm missing, but I just cant see it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 03:41:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7169625#M7942</guid>
      <dc:creator>ksd</dc:creator>
      <dc:date>2017-06-22T03:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7171009#M7943</link>
      <description>&lt;P&gt;That's still not enough info to try and reproduce&amp;nbsp; your situation with. Can you post a dvb and sample dwg?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 14:16:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7171009#M7943</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2017-06-22T14:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7171248#M7944</link>
      <description>&lt;P&gt;What data type is assigned to the blockLocation variable?&amp;nbsp; If assigned as a Double, there is no need to use CDbl which converts the value to a double.&amp;nbsp; Logically that alone shouldn't be a problem though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you use the Debug.Print statement in your code to output the current values of the blockLocation variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Debug.Print blockLocation(0)&lt;BR /&gt;&amp;nbsp; Debug.Print blockLocation(1)&lt;BR /&gt;&amp;nbsp; Debug.Print blockLocation(2)&lt;BR /&gt;&amp;nbsp; Debug.Print blockLocation(3)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output will go to the Immediate window in the VBA IDE upon execution during your program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you using a custom UCS by chance as well?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 15:15:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7171248#M7944</guid>
      <dc:creator>ambrosl</dc:creator>
      <dc:date>2017-06-22T15:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7172498#M7945</link>
      <description>&lt;P&gt;Yeah, the CDbl was an attempt to fix the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I put the debug code in:&lt;/P&gt;&lt;P&gt;Debug.Print "blockLocation(0 to 3)"&lt;BR /&gt;Debug.Print blockLocation(0)&lt;BR /&gt;Debug.Print blockLocation(1)&lt;BR /&gt;Debug.Print blockLocation(2)&lt;BR /&gt;Debug.Print blockLocation(3)&lt;BR /&gt;Debug.Print "pt1(0 to 2)"&lt;BR /&gt;Debug.Print pt1(0)&lt;BR /&gt;Debug.Print pt1(1)&lt;BR /&gt;Debug.Print pt1(2)&lt;BR /&gt;Debug.Print "pt2(0 to 2)"&lt;BR /&gt;Debug.Print pt2(0)&lt;BR /&gt;Debug.Print pt2(1)&lt;BR /&gt;Debug.Print pt2(2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Results:&lt;/P&gt;&lt;P&gt;blockLocation(0 to 3)&lt;BR /&gt;256833.405419725&lt;BR /&gt;5928142.14654379&lt;BR /&gt;256860.94223028&lt;BR /&gt;5928154.50562402&lt;BR /&gt;pt1(0 to 2)&lt;BR /&gt;256833.405419725&lt;BR /&gt;5928142.14654379&lt;BR /&gt;0&lt;BR /&gt;pt2(0 to 2)&lt;BR /&gt;256860.94223028&lt;BR /&gt;5928154.50562402&lt;BR /&gt;0&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 23:12:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7172498#M7945</guid>
      <dc:creator>ksd</dc:creator>
      <dc:date>2017-06-22T23:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7173803#M7946</link>
      <description>&lt;P&gt;Based on those numbers... I am getting an angle in Radians of 0.42187226 which&amp;nbsp;when converted is&amp;nbsp;24.1715 Degrees.&amp;nbsp; What value are you getting and expecting?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 13:46:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7173803#M7946</guid>
      <dc:creator>ambrosl</dc:creator>
      <dc:date>2017-06-23T13:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7180746#M7947</link>
      <description>&lt;P&gt;Hi Lee,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting an error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2017-06-27 11_59_46-Microsoft Visual Basic.jpg" style="width: 371px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/371693i8583C1E7955A4383/image-size/large?v=v2&amp;amp;px=999" role="button" title="2017-06-27 11_59_46-Microsoft Visual Basic.jpg" alt="2017-06-27 11_59_46-Microsoft Visual Basic.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I take the same coordinates (from the debug output) and manually set them in pt1() &amp;amp; pt2(), it works fine..&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>Tue, 27 Jun 2017 02:03:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7180746#M7947</guid>
      <dc:creator>ksd</dc:creator>
      <dc:date>2017-06-27T02:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7180805#M7948</link>
      <description>&lt;P&gt;Woooo! Figured it out...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It was to do with the way I was declaring pt1 and pt2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I declare it like this:&lt;/P&gt;&lt;PRE&gt;Dim pt1(0 To 2), pt2(0 To 2) As Double&lt;/PRE&gt;&lt;P&gt;It fails..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But like this:&lt;/P&gt;&lt;PRE&gt;Dim pt1(0 To 2) As Double
Dim pt2(0 To 2) As Double&lt;/PRE&gt;&lt;P&gt;It works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No idea why...&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 02:34:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7180805#M7948</guid>
      <dc:creator>ksd</dc:creator>
      <dc:date>2017-06-27T02:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7182508#M7949</link>
      <description>&lt;P&gt;Glad to hear you got it figured out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Dim pt1(0 To 2), pt2(0 To 2) As Double&lt;/FONT&gt; defines the first array as a Variant array and the second as a Double array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;AngleFromAxis&lt;/FONT&gt; function as you have seen from the change made and&amp;nbsp;the error message that you encountered expects a Double array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variable types of the arrays can be tested with the following statements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Dim pt1(0 To 2), pt2(0 To 2) As Double&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Debug.Print VarType(pt1)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Debug.Print VarType(pt2)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;8204&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;8197&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;8204 represents an Array (8192) of the Variant data type (12)&lt;/P&gt;
&lt;P&gt;8197 represents an Array (8192) of the Double data type (5)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 15:02:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7182508#M7949</guid>
      <dc:creator>ambrosl</dc:creator>
      <dc:date>2017-06-27T15:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7183399#M7950</link>
      <description>&lt;P&gt;Glad you figured it out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1706559"&gt;@ambrosl&lt;/a&gt; said, plus we may have pointed it out sooner if you posted your code.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 20:34:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7183399#M7950</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2017-06-27T20:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7183817#M7951</link>
      <description>&lt;P&gt;Ed, that may very well be the case, but as advised earlier, I am subject to an NDA for this work, so was not comfortable posting the full code.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 00:45:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7183817#M7951</guid>
      <dc:creator>ksd</dc:creator>
      <dc:date>2017-06-28T00:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: AngleFromXAxis</title>
      <link>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7185988#M7952</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;Ed, that may very well be the case, but as advised earlier, I am subject to an NDA for this work, so was not comfortable posting the full code.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't see where&amp;nbsp; you mentioned that part, but OK.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 14:22:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/anglefromxaxis/m-p/7185988#M7952</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2017-06-28T14:22:44Z</dc:date>
    </item>
  </channel>
</rss>

