程序中使用"break"命令截断需要被断开的管线,再用"arc"命令画一半圆连接两断点。变量p读取管线交点;p1、p2为点p的左右或上下两点;p3为连接p1、p2半圆的中点。由于使用"break"命令时若AUTOCAD环境处于对象捕捉方式(OSMODE≠0),则"break"命令截断的p1、p2两点可能为变为p1、p2附近的捕捉点。所以程序开始时用变量myosmode记录系统变量OSMODE,而后设置OSMODE为0,程序结束后再设置还原OSMODE。变量horn判断用户需要断开的是水平线还是垂直线。
(defun c:brel(/myosmode horv p p1 p2 p3)
(setq myosmode (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setq p (getpoint "\nselect point to break:"))
(initget 1 "H V")
(setq horv (getkword " Direction[H/V]?
(if (= horv "H")
(progn
(setq p1 (list (- (car p) 1.5) (cadr p)))
(setq p2 (list (+ (car p) 1.5) (cadr p)))
(setq p3 (list (car p) (+ (cadr p) 1.5)))
)
(progn
(setq p1 (list (car p) (- (cadr p) 1.5)))
(setq p2 (list (car p) (+ (cadr p) 1.5)))
(setq p3 (list (+ (car p) 1.5) (cadr p)))
)
)
(command "break" p1 p2)
(command "arc" p1 p3 p2)
(setvar "OSMODE" myosmode)
(princ)
)
(princ "\nStart command with brel which will break a line and join it with an arc.")