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

Draw Line Connecting Ends of 2 Parallel Lines with AutoLisp

有没有人有 AutoLisp 例程来快速绘制一条连接两条平行线的线。我真的很喜欢类似于圆角命令的东西,除了画一条直线而不是半径。这几乎可以通过倒角命令来完成,除了倒角不适用于平行线。

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

(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)
)