Community
How to find pt4 point or length of L line with vba.
pt3 is any coordinate point clicked.
Solved! Go to Solution.
Solved by Mesut_Akcan. Go to Solution.
I found a solution to my own question.
Sub Test_pt4() pi = 3.1415926535898 With ThisDrawing pt1 = .Utility.GetPoint(, "First point:") pt2 = .Utility.GetPoint(pt1, "Second point:") Set objLine = .ModelSpace.AddLine(pt1, pt2) pt3 = .Utility.GetPoint(pt2, "Third point:") ang = .Utility.AngleFromXAxis(pt1, pt3) x = pt3(0) - pt1(0) 'X y = pt3(1) - pt1(1) 'Y L = Sin(ang - objLine.Angle) * Sqr(x * x + y * y) ' Alternative ' L = (y - (Tan(objLine.Angle) * x)) * Cos(objLine.Angle) pt4 = .Utility.PolarPoint(pt2, objLine.Angle + pi / 2, L) .ModelSpace.AddLine pt2, pt4 .ModelSpace.AddLine pt3, pt4 End With End Sub
but my main goal was to draw a rectangle with 3 points
I reached my goal
codes below
Sub Rectangle3points() 'Mesut Akcan '05/08/2019 Dim pt1, pt2, pt3, pt4, points(0 To 7) As Double Dim ang, pi, t3, x, y, L Dim pl As AcadLWPolyline Dim objLine As AcadLine pi = 3.1415926535898 With ThisDrawing pt1 = .Utility.GetPoint(, "First point:") pt2 = .Utility.GetPoint(pt1, "Second point:") Set objLine = .ModelSpace.AddLine(pt1, pt2) objLine.color = acGreen objLine.Highlight True t3 = .Utility.GetPoint(pt2, "Third point:") ang = .Utility.AngleFromXAxis(pt1, t3) x = t3(0) - pt1(0) y = t3(1) - pt1(1) L = Sin(ang - objLine.Angle) * Sqr(x * x + y * y) ' Alternative ' L = (y - (Tan(objLine.Angle) * x)) * Cos(objLine.Angle) pt3 = .Utility.PolarPoint(pt2, objLine.Angle + pi / 2, L) pt4 = .Utility.PolarPoint(pt3, objLine.Angle + pi, objLine.Length) objLine.Delete points(0) = pt1(0): points(1) = pt1(1) '1. point X,Y points(2) = pt2(0): points(3) = pt2(1) '2. point points(4) = pt3(0): points(5) = pt3(1) '3. point points(6) = pt4(0): points(7) = pt4(1) '4. point Set pl = .ModelSpace.AddLightWeightPolyline(points) pl.Closed = True End With End Sub