使用AutoLisp绘制线连接2条平行线的末端

时间:2017-11-10 20:40:16

标签: parallel-processing line autocad autolisp

是否有人使用AutoLisp例程快速绘制连接两条平行线的线。我真的想要一些与圆角命令类似的东西,除了绘制直线而不是半径。这几乎可以使用倒角命令完成,但倒角不适用于平行线。

我的工作有时包括抵消许多平行线对,然后将它们与另一条线连接以创建矩形。只是在它们之间画一条线很容易,但它仍然是一个单调乏味的过程。

1 个答案:

答案 0 :(得分:2)

(defun c:connectLines (/ line1 line2 data1 data2 pt1 pt2 pt3 pt4)
  (and
    (setq line1 (car (entsel "\nSelect first line: ")))
    (= (cdr (assoc 0 (setq data1 (entget line1)))) "LINE")
    (setq line2 (car (entsel "\nSelect second line: ")))
    (= (cdr (assoc 0 (setq data2 (entget line2)))) "LINE")
    (setq pt1 (cdr (assoc 10 data1))
          pt2 (cdr (assoc 11 data1))
          pt3 (cdr (assoc 11 data2))
          pt4 (cdr (assoc 10 data2))
    )
    (or (< (distance pt2 pt3) (distance pt2 pt4))
        (mapcar 'set '(pt3 pt4) (list pt4 pt3))
    )
    (command "_.erase"
             (ssadd line2 (ssadd line1))
             ""
             "_.pline"
             "_non"
             (trans pt1 0 1)
             "_non"
             (trans pt2 0 1)
             "_non"
             (trans pt3 0 1)
             "_non"
             (trans pt4 0 1)
             "_close"
    )
  )
  (princ)
)