用 AutoLisp 画出连接两条平行线两端的线

问题描述 投票:0回答:2

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

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

parallel-processing line autocad autolisp
2个回答
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)
)

0
投票

非常有帮助!可以将其修改为仅拖动多行吗?

© www.soinside.com 2019 - 2024. All rights reserved.