<?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: in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327443#M91467</link>
    <description>&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;Rob, here is a way I came up with to &lt;BR /&gt;
do it using good ol geometry and some algebra (but without any trig!). It fails &lt;BR /&gt;
when the line is either vertical or horizontal though, but that should be easy &lt;BR /&gt;
to work around. Have a look at the code, watch out for word wrap! I'm sure there &lt;BR /&gt;
are many neat ways to do it with math - this is my "simple" &lt;BR /&gt;
version...&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&amp;nbsp; Dim oSpace As &lt;BR /&gt;
AcadObject&lt;BR /&gt;&amp;nbsp; Dim oLine1 As AcadLine, oLine2 As AcadLine&lt;BR /&gt;&amp;nbsp; Dim &lt;BR /&gt;
Pt1 As Variant, Pt2 As Variant&lt;BR /&gt;&amp;nbsp; Dim m1 As Double, m2 As Double, dX As &lt;BR /&gt;
Double, dY As Double, b1 As Double&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; 'GET THE CURRENT &lt;BR /&gt;
SPACE&lt;BR /&gt;&amp;nbsp; If ActiveDocument.ActiveSpace = acModelSpace &lt;BR /&gt;
Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set oSpace = ActiveDocument.ModelSpace&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;
Else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set oSpace = ActiveDocument.PaperSpace&lt;BR /&gt;&amp;nbsp; End &lt;BR /&gt;
If&lt;/FONT&gt;&lt;/DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; 'PICK OUR POINT&lt;BR /&gt;&amp;nbsp; Pt1 = ThisDrawing.Utility.GetPoint(, &lt;BR /&gt;
"Pick first point :")&lt;BR /&gt;&amp;nbsp; 'PICK OUR LINE (Pt2 IS NEVER USED)&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;
ThisDrawing.Utility.GetEntity oLine1, Pt2, "Perpendicular to: "&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;
&lt;BR /&gt;&amp;nbsp; 'CALCULATE SLOPE OF THE EXISTING LINE&lt;BR /&gt;&amp;nbsp; m1 = &lt;BR /&gt;
(oLine1.StartPoint(1) - oLine1.EndPoint(1)) / (oLine1.StartPoint(0) - &lt;BR /&gt;
oLine1.EndPoint(0))&lt;BR /&gt;&amp;nbsp; 'USE GEOMETRY: PERP LINES SLOPES' ARE NEGATIVE &lt;BR /&gt;
RECIPROCALS&lt;BR /&gt;&amp;nbsp; m2 = -1 / m1&lt;BR /&gt;&amp;nbsp; 'SOLVE FOR Y-ICEPT OF LINE1, WHICH &lt;BR /&gt;
WE'LL NEED LATER&lt;BR /&gt;&amp;nbsp; b1 = oLine1.StartPoint(1) - (m1 * &lt;BR /&gt;
oLine1.StartPoint(0))&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; 'WRITING THE SLOPE FORMULA FOR THE PERP LINE LEAVES AN "X" AND A &lt;BR /&gt;
"Y" UNKNOWN&lt;BR /&gt;&amp;nbsp; 'BY RE-ARRANGING WE CAN PLUG IN THE EQUATION OF THE LINE &lt;BR /&gt;
FOR "Y" AND SOLVE&lt;BR /&gt;&amp;nbsp; 'IN TERMS OF "X" (SCARY, DO IT ON PAPER IF YOU WANT &lt;BR /&gt;
TO SEE WHERE IT COMES FROM!)&lt;BR /&gt;&amp;nbsp; dX = ((Pt1(0) * m2) - (Pt1(1) - b1)) / &lt;BR /&gt;
(m2 - m1)&lt;BR /&gt;&amp;nbsp; 'NOW THAT WE HAVE "X" WE CAN SOLVE FOR "Y"&lt;BR /&gt;&amp;nbsp; dY = &lt;BR /&gt;
((Pt1(0) * m2) - (dX * m2) - Pt1(1)) * -1&lt;BR /&gt;&amp;nbsp; Pt2(0) = dX: Pt2(1) = &lt;BR /&gt;
dY&lt;BR /&gt;&amp;nbsp; 'FINALLY ADD THE LINE&lt;BR /&gt;&amp;nbsp; Set oLine2 = oSpace.AddLine(Pt1, &lt;BR /&gt;
Pt2)&lt;/DIV&gt;&lt;/FONT&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;Just to give you a "verbal" rundown &lt;BR /&gt;
of the math sequence in case you want to work it out...&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- Calculate slope of line &lt;BR /&gt;
(m1)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- Slopes of perp lines are always &lt;BR /&gt;
negative reciprocals so m2 = -1/m1&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- y=mx+b :solve for the y-icept &lt;BR /&gt;
(b)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- look at slope formula for perp. &lt;BR /&gt;
line (3-y) / (4-x) = 2 :subst eq. of line for y (y = mx+b)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- solve for x&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- solve for y&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- all done!&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&amp;nbsp; Jacob Dinardi&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"Rob Outman" &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:routman@nakata.com"&amp;gt;routman@nakata.com&lt;/A&gt;&amp;gt; wrote in message &lt;BR /&gt;
  &lt;A&gt;&lt;BR /&gt;
  href="news:B483578BDBC88ECC6B607EB14B182525@in.WebX.maYIadrTaRb"&amp;gt;news:B483578BDBC88ECC6B607EB14B182525@in.WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Hi All,&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;I read a previous message posted by Monica Eisfeld on 3/19/01 titled &lt;BR /&gt;
  "Draw Perpendicular Line?"&amp;nbsp; I am trying to do something similar.&amp;nbsp; I &lt;BR /&gt;
  have contacted Monica and she unfortunately never had a chance to work on this &lt;BR /&gt;
  tool.&amp;nbsp; Josh from Minkwitz design responded by saying:&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "The first thing you have to do is to determine where &lt;BR /&gt;
  the point is relative&lt;BR /&gt;to the line or vise versa. For instance if the point &lt;BR /&gt;
  is considered 0,0,0 in the&lt;BR /&gt;cartesian coordinate system, which quadrant &lt;BR /&gt;
  would the line fall in? After that,&lt;BR /&gt;perpendicularly is a breeze. You just &lt;BR /&gt;
  add the appropriate angle (in radians) to&lt;BR /&gt;the angle property of the &lt;BR /&gt;
  line."&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "A fairly simple way to pin down the location of &lt;BR /&gt;
  the line relative to the&lt;BR /&gt;point would be to create temporary lines form the &lt;BR /&gt;
  startpoint and endpoint of&lt;BR /&gt;the selected line to the selected point. You &lt;BR /&gt;
  could use the angle property of&lt;BR /&gt;those lines to pin down the &lt;BR /&gt;
  quadrant."&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Could someone point me in the right direction on how to code this?&amp;nbsp; &lt;BR /&gt;
  I am simply trying to have the user select a point on a line, select a second &lt;BR /&gt;
  line and have it automatically draw a new line from the selected point, &lt;BR /&gt;
  perpendicular to the second line that was picked.&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;I have tried to do this by setting the object snaps prior to drawing the &lt;BR /&gt;
  new line, but for some reason, it try's to draw the new&amp;nbsp;line&amp;nbsp;from &lt;BR /&gt;
  the selected point to the perpendicular of the first&amp;nbsp;point &lt;BR /&gt;
selected.&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Any thoughts?&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Rob&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Tue, 29 May 2001 19:24:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2001-05-29T19:24:41Z</dc:date>
    <item>
      <title>Perpendicular</title>
      <link>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327439#M91463</link>
      <description>Greetings All,&lt;BR /&gt;
This is my situation:  I have a block that is X distance from a curved&lt;BR /&gt;
pline.&lt;BR /&gt;
What I would like to do is draw a construction line from the insertion&lt;BR /&gt;
point of the block perpendicular to the pline.  Getting the InsPnt isn't&lt;BR /&gt;
a problem(first point of line), but how do I get that perpendicular&lt;BR /&gt;
point(second point of line)?  Any thoughts or ideas are thanked in&lt;BR /&gt;
advance.&lt;BR /&gt;
Eric Nagel</description>
      <pubDate>Fri, 04 Aug 2000 18:05:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327439#M91463</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2000-08-04T18:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Perpendicular</title>
      <link>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327440#M91464</link>
      <description>Hi Eric,&lt;BR /&gt;
    I thought I was going to have a formula or some code for you, but it&lt;BR /&gt;
doesn't look I'll have time today. It can be done, it's just a matter of&lt;BR /&gt;
doing the math and writing the code. Using the acadpolyline.coordinates&lt;BR /&gt;
array of points, create 3 lines to form a triangle between the points. Then&lt;BR /&gt;
create a fourth line from the bulge to the center of the longest line. The&lt;BR /&gt;
two shorter legs of the overall triangle form the bases of two isometric&lt;BR /&gt;
triangles. The fourth line gives you the angle of the isometric sides. The&lt;BR /&gt;
peak of the triangles (which will have to be trigged out) will be located on&lt;BR /&gt;
the center point of the arc. The length of the sides, the radius of the arc.&lt;BR /&gt;
Then you can use the polarpoint method to create a line through the center&lt;BR /&gt;
point at a distance of (the radius + the distance form the insertionpoint to&lt;BR /&gt;
the center point). Your line will be perpindicular to the arc. I know it&lt;BR /&gt;
sounds rough, but it's just a matter of adding a few more lines than&lt;BR /&gt;
intended and deleting them afterward. Here's a jpeg of what I'm trying to&lt;BR /&gt;
relay, hope it helps (darn mail convertor darkens it up). If you don't have&lt;BR /&gt;
it done by Monday, I'll try to find some time (Mondays are always busier&lt;BR /&gt;
than Fridays) and come up with a formula and maybe even a little code.&lt;BR /&gt;
-Josh&lt;BR /&gt;
[Image]&lt;BR /&gt;
&lt;BR /&gt;
Eric Nagel wrote:&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; Greetings All,&lt;BR /&gt;
&amp;gt; This is my situation:  I have a block that is X distance from a curved&lt;BR /&gt;
&amp;gt; pline.&lt;BR /&gt;
&amp;gt; What I would like to do is draw a construction line from the insertion&lt;BR /&gt;
&amp;gt; point of the block perpendicular to the pline.  Getting the InsPnt isn't&lt;BR /&gt;
&amp;gt; a problem(first point of line), but how do I get that perpendicular&lt;BR /&gt;
&amp;gt; point(second point of line)?  Any thoughts or ideas are thanked in&lt;BR /&gt;
&amp;gt; advance.&lt;BR /&gt;
&amp;gt; Eric Nagel</description>
      <pubDate>Fri, 04 Aug 2000 21:06:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327440#M91464</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2000-08-04T21:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: Perpendicular</title>
      <link>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327441#M91465</link>
      <description>Here it is Eric,&lt;BR /&gt;
    The line will always fall perpendicular to the inside (concave) portion&lt;BR /&gt;
of the arc, even if the arc doesn't extend far enough.&lt;BR /&gt;
&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Private Function Radians(Degrees As Double) As Double&lt;BR /&gt;
Radians = Degrees / 180 * 3.141592654&lt;BR /&gt;
End Function&lt;BR /&gt;
Private Function Degrees(Radians As Double) As Double&lt;BR /&gt;
Degrees = Radians / 3.141592654 * 180&lt;BR /&gt;
End Function&lt;BR /&gt;
Sub Perp2Arc()&lt;BR /&gt;
Dim Parc As AcadLWPolyline&lt;BR /&gt;
Dim Blk As AcadBlockReference&lt;BR /&gt;
Dim Ent As AcadEntity&lt;BR /&gt;
Dim Ent2 As AcadEntity&lt;BR /&gt;
Dim ArcPt, BlkPt&lt;BR /&gt;
Dim Bulg As Double&lt;BR /&gt;
Do  'Select a polyline arc&lt;BR /&gt;
    Set Ent = Nothing&lt;BR /&gt;
    'On Error Resume Next&lt;BR /&gt;
    ThisDrawing.Utility.GetEntity Ent, ArcPt, vbCr &amp;amp; "Select a PolyLine Arc&lt;BR /&gt;
: "&lt;BR /&gt;
    If Err Then&lt;BR /&gt;
        If ThisDrawing.GetVariable("ERRNO") = 52 Then&lt;BR /&gt;
            Err.Clear&lt;BR /&gt;
            Exit Sub&lt;BR /&gt;
        End If&lt;BR /&gt;
    End If&lt;BR /&gt;
    If Not Ent Is Nothing Then&lt;BR /&gt;
        If TypeOf Ent Is AcadLWPolyline Then&lt;BR /&gt;
            Set Parc = Ent&lt;BR /&gt;
            Bulg = Parc.GetBulge(0) 'verify pline arc - won't work unless&lt;BR /&gt;
the 1st segment is an arc&lt;BR /&gt;
            If Bulg = 0# Then&lt;BR /&gt;
                MsgBox "The PolyLine You Selected Is Not an Arc. Try Again."&lt;BR /&gt;
&lt;BR /&gt;
            Else&lt;BR /&gt;
                Exit Do&lt;BR /&gt;
            End If&lt;BR /&gt;
        Else&lt;BR /&gt;
            MsgBox "You Did Not Select a PolyLine Arc. Try Again."&lt;BR /&gt;
        End If&lt;BR /&gt;
    End If&lt;BR /&gt;
Loop&lt;BR /&gt;
Do  'Select a block reference&lt;BR /&gt;
    Set Ent2 = Nothing&lt;BR /&gt;
    ThisDrawing.Utility.GetEntity Ent2, BlkPt, vbCr &amp;amp; "Select a Block : "&lt;BR /&gt;
    If Err Then&lt;BR /&gt;
        If ThisDrawing.GetVariable("ERRNO") = 52 Then&lt;BR /&gt;
            Err.Clear&lt;BR /&gt;
            Exit Sub&lt;BR /&gt;
        End If&lt;BR /&gt;
    End If&lt;BR /&gt;
    If Not Ent2 Is Nothing Then&lt;BR /&gt;
        If TypeOf Ent2 Is AcadBlockReference Then&lt;BR /&gt;
            Set Blk = Ent2&lt;BR /&gt;
            Exit Do&lt;BR /&gt;
        Else&lt;BR /&gt;
            MsgBox "You Did Not Select a Block. Try Again."&lt;BR /&gt;
        End If&lt;BR /&gt;
    End If&lt;BR /&gt;
Loop&lt;BR /&gt;
'begin construction lines &amp;amp; math&lt;BR /&gt;
Dim Lin1 As AcadLine&lt;BR /&gt;
Dim Lin2 As AcadLine&lt;BR /&gt;
Dim Ang As Double&lt;BR /&gt;
Dim ClockWise As Boolean&lt;BR /&gt;
Dim RadAng As Double&lt;BR /&gt;
Dim IsoAng As Double&lt;BR /&gt;
Dim Radius As Double&lt;BR /&gt;
Dim CentrPt, PolarPt, PolyPts As Variant&lt;BR /&gt;
Dim Sp(0 To 2) As Double&lt;BR /&gt;
Dim Ep(0 To 2) As Double&lt;BR /&gt;
PolyPts = Parc.Coordinates  'elements 0 &amp;amp; 1 are the startpoint, 2 &amp;amp; 3 are&lt;BR /&gt;
the endpoint&lt;BR /&gt;
Sp(0) = PolyPts(0): Sp(1) = PolyPts(1)&lt;BR /&gt;
Ep(0) = PolyPts(2): Ep(1) = PolyPts(3)&lt;BR /&gt;
Set Lin1 = ThisDrawing.ModelSpace.AddLine(Sp, Ep)&lt;BR /&gt;
Ang = Atn(Bulg) * 4 'arctangent of bulge times 4 = angle of arc&lt;BR /&gt;
IsoAng = Degrees(Ang)   'determine angle of the two base angles&lt;BR /&gt;
If IsoAng &amp;lt; 0 Then&lt;BR /&gt;
    IsoAng = 180 + IsoAng&lt;BR /&gt;
    ClockWise = True&lt;BR /&gt;
Else&lt;BR /&gt;
    IsoAng = 180 - IsoAng&lt;BR /&gt;
End If&lt;BR /&gt;
IsoAng = IsoAng / 2&lt;BR /&gt;
IsoAng = Radians(IsoAng)&lt;BR /&gt;
If ClockWise Then&lt;BR /&gt;
    RadAng = Lin1.Angle + IsoAng + Radians(180) 'angle from endpt of arc to&lt;BR /&gt;
centerpoint&lt;BR /&gt;
Else&lt;BR /&gt;
    RadAng = Lin1.Angle - IsoAng + Radians(180) 'angle from endpt of arc to&lt;BR /&gt;
centerpoint&lt;BR /&gt;
End If&lt;BR /&gt;
Radius = (Lin1.Length / 2) / Cos(IsoAng)    'determine radius&lt;BR /&gt;
CentrPt = ThisDrawing.Utility.PolarPoint(Ep, RadAng, Radius)   'determine&lt;BR /&gt;
center point&lt;BR /&gt;
Set Lin2 = ThisDrawing.ModelSpace.AddLine(Blk.InsertionPoint, CentrPt)&lt;BR /&gt;
PolarPt = ThisDrawing.Utility.PolarPoint(CentrPt, Lin2.Angle, Radius)&lt;BR /&gt;
'use lin2.angle + radians(180) to force the line to fall to the outside of&lt;BR /&gt;
the arc&lt;BR /&gt;
Lin1.Delete&lt;BR /&gt;
Lin2.Delete&lt;BR /&gt;
Set Lin2 = ThisDrawing.ModelSpace.AddLine(Blk.InsertionPoint, PolarPt)&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
-Josh&lt;BR /&gt;
&lt;BR /&gt;
Eric Nagel wrote:&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; Greetings All,&lt;BR /&gt;
&amp;gt; This is my situation:  I have a block that is X distance from a curved&lt;BR /&gt;
&amp;gt; pline.&lt;BR /&gt;
&amp;gt; What I would like to do is draw a construction line from the insertion&lt;BR /&gt;
&amp;gt; point of the block perpendicular to the pline.  Getting the InsPnt isn't&lt;BR /&gt;
&amp;gt; a problem(first point of line), but how do I get that perpendicular&lt;BR /&gt;
&amp;gt; point(second point of line)?  Any thoughts or ideas are thanked in&lt;BR /&gt;
&amp;gt; advance.&lt;BR /&gt;
&amp;gt; Eric Nagel</description>
      <pubDate>Tue, 08 Aug 2000 20:31:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327441#M91465</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2000-08-08T20:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Perpendicular</title>
      <link>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327442#M91466</link>
      <description>&lt;DIV&gt;Hi All,&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;I read a previous message posted by Monica Eisfeld on 3/19/01 titled "Draw &lt;BR /&gt;
Perpendicular Line?"&amp;nbsp; I am trying to do something similar.&amp;nbsp; I have &lt;BR /&gt;
contacted Monica and she unfortunately never had a chance to work on this &lt;BR /&gt;
tool.&amp;nbsp; Josh from Minkwitz design responded by saying:&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "The first thing you have to do is to determine where &lt;BR /&gt;
the point is relative&lt;BR /&gt;to the line or vise versa. For instance if the point is &lt;BR /&gt;
considered 0,0,0 in the&lt;BR /&gt;cartesian coordinate system, which quadrant would the &lt;BR /&gt;
line fall in? After that,&lt;BR /&gt;perpendicularly is a breeze. You just add the &lt;BR /&gt;
appropriate angle (in radians) to&lt;BR /&gt;the angle property of the line."&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "A fairly simple way to pin down the location of the &lt;BR /&gt;
line relative to the&lt;BR /&gt;point would be to create temporary lines form the &lt;BR /&gt;
startpoint and endpoint of&lt;BR /&gt;the selected line to the selected point. You could &lt;BR /&gt;
use the angle property of&lt;BR /&gt;those lines to pin down the quadrant."&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;Could someone point me in the right direction on how to code this?&amp;nbsp; I &lt;BR /&gt;
am simply trying to have the user select a point on a line, select a second line &lt;BR /&gt;
and have it automatically draw a new line from the selected point, perpendicular &lt;BR /&gt;
to the second line that was picked.&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;I have tried to do this by setting the object snaps prior to drawing the &lt;BR /&gt;
new line, but for some reason, it try's to draw the new&amp;nbsp;line&amp;nbsp;from the &lt;BR /&gt;
selected point to the perpendicular of the first&amp;nbsp;point selected.&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;Any thoughts?&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;Rob&lt;/DIV&gt;</description>
      <pubDate>Tue, 29 May 2001 13:42:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327442#M91466</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-29T13:42:33Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327443#M91467</link>
      <description>&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;Rob, here is a way I came up with to &lt;BR /&gt;
do it using good ol geometry and some algebra (but without any trig!). It fails &lt;BR /&gt;
when the line is either vertical or horizontal though, but that should be easy &lt;BR /&gt;
to work around. Have a look at the code, watch out for word wrap! I'm sure there &lt;BR /&gt;
are many neat ways to do it with math - this is my "simple" &lt;BR /&gt;
version...&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&amp;nbsp; Dim oSpace As &lt;BR /&gt;
AcadObject&lt;BR /&gt;&amp;nbsp; Dim oLine1 As AcadLine, oLine2 As AcadLine&lt;BR /&gt;&amp;nbsp; Dim &lt;BR /&gt;
Pt1 As Variant, Pt2 As Variant&lt;BR /&gt;&amp;nbsp; Dim m1 As Double, m2 As Double, dX As &lt;BR /&gt;
Double, dY As Double, b1 As Double&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; 'GET THE CURRENT &lt;BR /&gt;
SPACE&lt;BR /&gt;&amp;nbsp; If ActiveDocument.ActiveSpace = acModelSpace &lt;BR /&gt;
Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set oSpace = ActiveDocument.ModelSpace&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;
Else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set oSpace = ActiveDocument.PaperSpace&lt;BR /&gt;&amp;nbsp; End &lt;BR /&gt;
If&lt;/FONT&gt;&lt;/DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; 'PICK OUR POINT&lt;BR /&gt;&amp;nbsp; Pt1 = ThisDrawing.Utility.GetPoint(, &lt;BR /&gt;
"Pick first point :")&lt;BR /&gt;&amp;nbsp; 'PICK OUR LINE (Pt2 IS NEVER USED)&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;
ThisDrawing.Utility.GetEntity oLine1, Pt2, "Perpendicular to: "&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;
&lt;BR /&gt;&amp;nbsp; 'CALCULATE SLOPE OF THE EXISTING LINE&lt;BR /&gt;&amp;nbsp; m1 = &lt;BR /&gt;
(oLine1.StartPoint(1) - oLine1.EndPoint(1)) / (oLine1.StartPoint(0) - &lt;BR /&gt;
oLine1.EndPoint(0))&lt;BR /&gt;&amp;nbsp; 'USE GEOMETRY: PERP LINES SLOPES' ARE NEGATIVE &lt;BR /&gt;
RECIPROCALS&lt;BR /&gt;&amp;nbsp; m2 = -1 / m1&lt;BR /&gt;&amp;nbsp; 'SOLVE FOR Y-ICEPT OF LINE1, WHICH &lt;BR /&gt;
WE'LL NEED LATER&lt;BR /&gt;&amp;nbsp; b1 = oLine1.StartPoint(1) - (m1 * &lt;BR /&gt;
oLine1.StartPoint(0))&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp; 'WRITING THE SLOPE FORMULA FOR THE PERP LINE LEAVES AN "X" AND A &lt;BR /&gt;
"Y" UNKNOWN&lt;BR /&gt;&amp;nbsp; 'BY RE-ARRANGING WE CAN PLUG IN THE EQUATION OF THE LINE &lt;BR /&gt;
FOR "Y" AND SOLVE&lt;BR /&gt;&amp;nbsp; 'IN TERMS OF "X" (SCARY, DO IT ON PAPER IF YOU WANT &lt;BR /&gt;
TO SEE WHERE IT COMES FROM!)&lt;BR /&gt;&amp;nbsp; dX = ((Pt1(0) * m2) - (Pt1(1) - b1)) / &lt;BR /&gt;
(m2 - m1)&lt;BR /&gt;&amp;nbsp; 'NOW THAT WE HAVE "X" WE CAN SOLVE FOR "Y"&lt;BR /&gt;&amp;nbsp; dY = &lt;BR /&gt;
((Pt1(0) * m2) - (dX * m2) - Pt1(1)) * -1&lt;BR /&gt;&amp;nbsp; Pt2(0) = dX: Pt2(1) = &lt;BR /&gt;
dY&lt;BR /&gt;&amp;nbsp; 'FINALLY ADD THE LINE&lt;BR /&gt;&amp;nbsp; Set oLine2 = oSpace.AddLine(Pt1, &lt;BR /&gt;
Pt2)&lt;/DIV&gt;&lt;/FONT&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;Just to give you a "verbal" rundown &lt;BR /&gt;
of the math sequence in case you want to work it out...&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- Calculate slope of line &lt;BR /&gt;
(m1)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- Slopes of perp lines are always &lt;BR /&gt;
negative reciprocals so m2 = -1/m1&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- y=mx+b :solve for the y-icept &lt;BR /&gt;
(b)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- look at slope formula for perp. &lt;BR /&gt;
line (3-y) / (4-x) = 2 :subst eq. of line for y (y = mx+b)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- solve for x&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- solve for y&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;- all done!&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" color="#000000" size="2"&gt;&amp;nbsp; Jacob Dinardi&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"Rob Outman" &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:routman@nakata.com"&amp;gt;routman@nakata.com&lt;/A&gt;&amp;gt; wrote in message &lt;BR /&gt;
  &lt;A&gt;&lt;BR /&gt;
  href="news:B483578BDBC88ECC6B607EB14B182525@in.WebX.maYIadrTaRb"&amp;gt;news:B483578BDBC88ECC6B607EB14B182525@in.WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Hi All,&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;I read a previous message posted by Monica Eisfeld on 3/19/01 titled &lt;BR /&gt;
  "Draw Perpendicular Line?"&amp;nbsp; I am trying to do something similar.&amp;nbsp; I &lt;BR /&gt;
  have contacted Monica and she unfortunately never had a chance to work on this &lt;BR /&gt;
  tool.&amp;nbsp; Josh from Minkwitz design responded by saying:&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "The first thing you have to do is to determine where &lt;BR /&gt;
  the point is relative&lt;BR /&gt;to the line or vise versa. For instance if the point &lt;BR /&gt;
  is considered 0,0,0 in the&lt;BR /&gt;cartesian coordinate system, which quadrant &lt;BR /&gt;
  would the line fall in? After that,&lt;BR /&gt;perpendicularly is a breeze. You just &lt;BR /&gt;
  add the appropriate angle (in radians) to&lt;BR /&gt;the angle property of the &lt;BR /&gt;
  line."&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "A fairly simple way to pin down the location of &lt;BR /&gt;
  the line relative to the&lt;BR /&gt;point would be to create temporary lines form the &lt;BR /&gt;
  startpoint and endpoint of&lt;BR /&gt;the selected line to the selected point. You &lt;BR /&gt;
  could use the angle property of&lt;BR /&gt;those lines to pin down the &lt;BR /&gt;
  quadrant."&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Could someone point me in the right direction on how to code this?&amp;nbsp; &lt;BR /&gt;
  I am simply trying to have the user select a point on a line, select a second &lt;BR /&gt;
  line and have it automatically draw a new line from the selected point, &lt;BR /&gt;
  perpendicular to the second line that was picked.&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;I have tried to do this by setting the object snaps prior to drawing the &lt;BR /&gt;
  new line, but for some reason, it try's to draw the new&amp;nbsp;line&amp;nbsp;from &lt;BR /&gt;
  the selected point to the perpendicular of the first&amp;nbsp;point &lt;BR /&gt;
selected.&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Any thoughts?&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Rob&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 29 May 2001 19:24:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327443#M91467</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-29T19:24:41Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327444#M91468</link>
      <description>&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;This works in 2D or 3D and will calculate the &lt;BR /&gt;
theoretical perpendicular point.&amp;nbsp; I included a test routine after the &lt;BR /&gt;
PointPerpendicular.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Hope this helps.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Function PointPerpendicular(PointToProject As &lt;BR /&gt;
Variant, StartPoint As Variant, EndPoint As Variant) As Variant&lt;BR /&gt;' This &lt;BR /&gt;
routine calculates the projection of a point (PointToProject)&lt;BR /&gt;' onto a &lt;BR /&gt;
theoretical line between StartPoint and EndPoint using the&lt;BR /&gt;' dot product of &lt;BR /&gt;
two vectors.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;' The resultant vector of the following &lt;BR /&gt;
algorithm&lt;BR /&gt;' represents the point's distance and direction from &lt;BR /&gt;
StartPoint.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial"&gt;&lt;BR /&gt;
size=2&amp;gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
/&amp;nbsp; U . V&amp;nbsp; \&lt;BR /&gt;'&amp;nbsp; projection of U on V = |&amp;nbsp; -------&amp;nbsp; | &lt;BR /&gt;
V&lt;BR /&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
\ ||V||^2 /&lt;BR /&gt;'&lt;BR /&gt;' where:&lt;BR /&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp; U = vector between &lt;BR /&gt;
StartPoint and PointToProject&lt;BR /&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp; V = vector between &lt;BR /&gt;
StartPoint and EndPoint&lt;BR /&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp; U.V = dot product of two &lt;BR /&gt;
vectors&lt;BR /&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp; ||V|| = length of vector V&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' define &lt;BR /&gt;
vectors&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim u(0 To 2) As Double&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; u(0) &lt;BR /&gt;
= PointToProject(0) - StartPoint(0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; u(1) = &lt;BR /&gt;
PointToProject(1) - StartPoint(1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; u(2) = PointToProject(2) &lt;BR /&gt;
- StartPoint(2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim v(0 To 2) As &lt;BR /&gt;
Double&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; v(0) = EndPoint(0) - &lt;BR /&gt;
StartPoint(0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; v(1) = EndPoint(1) - &lt;BR /&gt;
StartPoint(1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; v(2) = EndPoint(2) - &lt;BR /&gt;
StartPoint(2)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' ensure vectors are not &lt;BR /&gt;
parallel&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If u(0) = v(0) And u(1) = v(1) And u(2) = v(2) &lt;BR /&gt;
Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox "The three points &lt;BR /&gt;
define a straight line", vbCritical, "Error: ThreePointUCS: Invalid &lt;BR /&gt;
Input"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit &lt;BR /&gt;
Function&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' calculate dot product of U and &lt;BR /&gt;
V&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim uDOTv As Double&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uDOTv = u(0) * &lt;BR /&gt;
v(0) + u(1) * v(1) + u(2) * v(2)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' calculate length of &lt;BR /&gt;
V&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim vLength As Double&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vLength = &lt;BR /&gt;
(v(0) ^ 2 + v(1) ^ 2 + v(2) ^ 2) ^ 0.5&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' calculate projected &lt;BR /&gt;
vector&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim projectUonV(0 To 2) As &lt;BR /&gt;
Double&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; projectUonV(0) = (uDOTv / vLength ^ 2) * &lt;BR /&gt;
v(0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; projectUonV(1) = (uDOTv / vLength ^ 2) * &lt;BR /&gt;
v(1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; projectUonV(2) = (uDOTv / vLength ^ 2) * &lt;BR /&gt;
v(2)&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' return &lt;BR /&gt;
results&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim ProjectedPoint(0 To 2) As &lt;BR /&gt;
Double&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProjectedPoint(0) = StartPoint(0) + &lt;BR /&gt;
projectUonV(0)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProjectedPoint(1) = StartPoint(1) + &lt;BR /&gt;
projectUonV(1)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProjectedPoint(2) = StartPoint(2) + &lt;BR /&gt;
projectUonV(2)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PointPerpendicular = ProjectedPoint&lt;BR /&gt;End &lt;BR /&gt;
Function&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Sub testPointPerpendicular()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
Dim ln1 As AcadLine&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim p1 As &lt;BR /&gt;
Variant&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pt As Variant&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; p1 = &lt;BR /&gt;
ThisDrawing.Utility.GetPoint(, "Select point")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
ThisDrawing.Utility.GetEntity ln1, pt, "Select second &lt;BR /&gt;
line"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = PointPerpendicular(p1, ln1.StartPoint, &lt;BR /&gt;
ln1.EndPoint)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim l1 As AcadLine&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set &lt;BR /&gt;
l1 = ThisDrawing.ModelSpace.AddLine(p1, pt)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
l1.Update&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set l1 = Nothing&lt;BR /&gt;End Sub&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;Rob Outman &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:routman@nakata.com"&amp;gt;routman@nakata.com&lt;/A&gt;&amp;gt; wrote in message &lt;BR /&gt;
  &lt;A&gt;&lt;BR /&gt;
  href="news:B483578BDBC88ECC6B607EB14B182525@in.WebX.maYIadrTaRb"&amp;gt;news:B483578BDBC88ECC6B607EB14B182525@in.WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Hi All,&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;I read a previous message posted by Monica Eisfeld on 3/19/01 titled &lt;BR /&gt;
  "Draw Perpendicular Line?"&amp;nbsp; I am trying to do something similar.&amp;nbsp; I &lt;BR /&gt;
  have contacted Monica and she unfortunately never had a chance to work on this &lt;BR /&gt;
  tool.&amp;nbsp; Josh from Minkwitz design responded by saying:&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "The first thing you have to do is to determine where &lt;BR /&gt;
  the point is relative&lt;BR /&gt;to the line or vise versa. For instance if the point &lt;BR /&gt;
  is considered 0,0,0 in the&lt;BR /&gt;cartesian coordinate system, which quadrant &lt;BR /&gt;
  would the line fall in? After that,&lt;BR /&gt;perpendicularly is a breeze. You just &lt;BR /&gt;
  add the appropriate angle (in radians) to&lt;BR /&gt;the angle property of the &lt;BR /&gt;
  line."&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "A fairly simple way to pin down the location of &lt;BR /&gt;
  the line relative to the&lt;BR /&gt;point would be to create temporary lines form the &lt;BR /&gt;
  startpoint and endpoint of&lt;BR /&gt;the selected line to the selected point. You &lt;BR /&gt;
  could use the angle property of&lt;BR /&gt;those lines to pin down the &lt;BR /&gt;
  quadrant."&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Could someone point me in the right direction on how to code this?&amp;nbsp; &lt;BR /&gt;
  I am simply trying to have the user select a point on a line, select a second &lt;BR /&gt;
  line and have it automatically draw a new line from the selected point, &lt;BR /&gt;
  perpendicular to the second line that was picked.&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;I have tried to do this by setting the object snaps prior to drawing the &lt;BR /&gt;
  new line, but for some reason, it try's to draw the new&amp;nbsp;line&amp;nbsp;from &lt;BR /&gt;
  the selected point to the perpendicular of the first&amp;nbsp;point &lt;BR /&gt;
selected.&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Any thoughts?&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Rob&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 30 May 2001 05:15:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327444#M91468</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-30T05:15:36Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327445#M91469</link>
      <description>&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Thanx Guys,&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;This is exactly what I am looking for.&amp;nbsp; They &lt;BR /&gt;
both work great!&amp;nbsp; It's amazing how two completely different code sets can &lt;BR /&gt;
do the exact same thing!&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Thanx again,&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT face="Arial" size="2"&gt;Rob&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE dir="ltr"&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;"Rob Outman" &amp;lt;&lt;A&gt;&lt;BR /&gt;
  href="mailto:routman@nakata.com"&amp;gt;routman@nakata.com&lt;/A&gt;&amp;gt; wrote in message &lt;BR /&gt;
  &lt;A&gt;&lt;BR /&gt;
  href="news:B483578BDBC88ECC6B607EB14B182525@in.WebX.maYIadrTaRb"&amp;gt;news:B483578BDBC88ECC6B607EB14B182525@in.WebX.maYIadrTaRb&lt;/A&gt;...&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Hi All,&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;I read a previous message posted by Monica Eisfeld on 3/19/01 titled &lt;BR /&gt;
  "Draw Perpendicular Line?"&amp;nbsp; I am trying to do something similar.&amp;nbsp; I &lt;BR /&gt;
  have contacted Monica and she unfortunately never had a chance to work on this &lt;BR /&gt;
  tool.&amp;nbsp; Josh from Minkwitz design responded by saying:&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "The first thing you have to do is to determine where &lt;BR /&gt;
  the point is relative&lt;BR /&gt;to the line or vise versa. For instance if the point &lt;BR /&gt;
  is considered 0,0,0 in the&lt;BR /&gt;cartesian coordinate system, which quadrant &lt;BR /&gt;
  would the line fall in? After that,&lt;BR /&gt;perpendicularly is a breeze. You just &lt;BR /&gt;
  add the appropriate angle (in radians) to&lt;BR /&gt;the angle property of the &lt;BR /&gt;
  line."&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "A fairly simple way to pin down the location of &lt;BR /&gt;
  the line relative to the&lt;BR /&gt;point would be to create temporary lines form the &lt;BR /&gt;
  startpoint and endpoint of&lt;BR /&gt;the selected line to the selected point. You &lt;BR /&gt;
  could use the angle property of&lt;BR /&gt;those lines to pin down the &lt;BR /&gt;
  quadrant."&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Could someone point me in the right direction on how to code this?&amp;nbsp; &lt;BR /&gt;
  I am simply trying to have the user select a point on a line, select a second &lt;BR /&gt;
  line and have it automatically draw a new line from the selected point, &lt;BR /&gt;
  perpendicular to the second line that was picked.&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;I have tried to do this by setting the object snaps prior to drawing the &lt;BR /&gt;
  new line, but for some reason, it try's to draw the new&amp;nbsp;line&amp;nbsp;from &lt;BR /&gt;
  the selected point to the perpendicular of the first&amp;nbsp;point &lt;BR /&gt;
selected.&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Any thoughts?&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
  &lt;DIV&gt;Rob&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 30 May 2001 05:54:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/perpendicular/m-p/327445#M91469</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2001-05-30T05:54:42Z</dc:date>
    </item>
  </channel>
</rss>

