Sub ch2()
Dim p1 As Variant
Dim p2 As Variant
Dim p4 As Variant
Dim p3 As Variant
' 获取用户输入的点
p1 = ThisDrawing.Utility.GetPoint
p2 = ThisDrawing.Utility.GetPoint
p3 = ThisDrawing.Utility.GetPoint
' 根据这些点创建二维多段线
Dim polyObj As AcadLWPolyline
Dim vertices(0 To 3) As Double
vertices(0) = p1(0): vertices(1) = p1(1)
vertices(2) = p2(0): vertices(3) = p2(1)
Set polyObj = ThisDrawing.ModelSpace.AddLightWeightPolyline _
(vertices)
p3 = ThisDrawing.Utility.GetPoint
Dim d As Double
d = (p2(1) - p1(1)) / (p2(0) - p1(0))
p4(0) = (p3(1) - p1(1) + d * p1(0) + (1 / d) * p3(0)) / ((1 / d) + d)
p4(1) = d * p4(0) - p1(0) * d + p1(1)
Dim pointObj As AcadPoint
Set pointObj = ThisDrawing.ModelSpace.AddPoint(p4)
ThisDrawing.SetVariable "PDMODE", 34
ThisDrawing.SetVariable "PDSIZE", 1
ZoomAll