请教,怎样才能用autolisp在直线两端各加一个矩形?
本人不会autolisp。请教,怎样才能用autolisp在直线两端各加一个矩形?比如在白色直线的两端各加一个1*5的矩形?你是直线先画出,再加矩形,还是画直线的同时,加上矩形,一次完成? 我用VBA实现。 Sub creatEndRect()
Dim line2 As AcadLine
ThisDrawing.Utility.GetEntity line2, basePnt, "Select an line:"
Dim p1
p1 = line2.startPoint
Dim p2
p2 = line2.endPoint
Dim angle2 As Double
angle2 = line2.angle
Dim pts1(0 To 7) As Double
Dim pts2(0 To 7) As Double
pts1(0) = CDbl(p1(0)) + 0.5 * Sin(angle2): pts1(1) = CDbl(p1(1)) - 0.5 * Cos(angle2)
pts1(2) = pts1(0) + 5 * Cos(angle2): pts1(3) = pts1(1) + 5 * Sin(angle2)
pts1(4) = pts1(2) - 1 * Sin(angle2): pts1(5) = pts1(3) + 1 * Cos(angle2)
pts1(6) = pts1(4) - 5 * Cos(angle2): pts1(7) = pts1(5) - 5 * Sin(angle2)
pts2(0) = CDbl(p2(0)) + 0.5 * Sin(angle2): pts2(1) = CDbl(p2(1)) - 0.5 * Cos(angle2)
pts2(2) = pts2(0) - 5 * Cos(angle2): pts2(3) = pts2(1) - 5 * Sin(angle2)
pts2(4) = pts2(2) - 1 * Sin(angle2): pts2(5) = pts2(3) + 1 * Cos(angle2)
pts2(6) = pts2(4) + 5 * Cos(angle2): pts2(7) = pts2(5) + 5 * Sin(angle2)
Dim pl0 As AcadLWPolyline
Set pl0 = ThisDrawing.ModelSpace.AddLightWeightPolyline(pts1)
Dim pl1 As AcadLWPolyline
Set pl1 = ThisDrawing.ModelSpace.AddLightWeightPolyline(pts2)
pl0.Closed = True
pl1.Closed = True
End Sub 不客气!管用就好!
页:
[1]