AUTOCAD中自動(dòng)生成45°視圖
/ 2021/6/5 10:43:45
次
畫管路圖時(shí),常畫俯視圖和相應(yīng)的45°角視圖。其實(shí)45°角視圖中包含的信息只比俯視圖中多了每根管路的水平高度。下面這個(gè)用
LISP編寫的程序可以自動(dòng)將俯視圖轉(zhuǎn)化為同一水平高度的45°角視圖,使用者只需在轉(zhuǎn)化后的圖上將每組管路在豎直方向上移動(dòng)相應(yīng)的高度,一幅45°角視圖就輕松完成了。
由于每根管路用一直線表示,所以只需改變直線的起點(diǎn)和終點(diǎn)
坐標(biāo)為相應(yīng)的45°角視圖中的坐標(biāo)。程序中變量p0記錄45°角視圖的坐標(biāo)原點(diǎn),由用戶輸入。p1記錄直線的起點(diǎn)坐標(biāo),
p2記錄直線的終點(diǎn)坐標(biāo)。
(defun c:V45( / cmdmode sset ssl ent p0,p1,p2,x1,x2,y0,y1,y2,
z1,z2)
(setq cmdmode (getvar "cmdecho"))
(setvar "cmdecho" 0)
;select lines by
user(prompt "\nselect lines:")
(setq sset (ssget))
(
if (
not(
null sset))
(progn
(setq ssl (sslength sset))
;
input base point by user
(setq p0 (getpoint "\nThe base point: "))
(setq y0 (cadr p0))
(while (> ssl 0)
(setq ent(entget (ssname sset (setq ssl (1- ssl)))))
;
filter the lines
(if (= (
cdr (assoc 0 ent)) "
LINE")
;change the
start point and end point of the line
(progn
(setq x1 (cadr(assoc 10 ent)))
(setq y1 (caddr(assoc 10 ent)))
(setq z1 (cadddr(assoc 10 ent)))
(setq x2 (cadr(assoc 11 ent)))
(setq y2 (caddr(assoc 11 ent)))
(setq z2 (cadddr(assoc 11 ent)))
(setq p1 (
list (+ x1 (/ (* (
sqrt 2) (- y1 y0)) 4)) (+ y0 (/ (* (sqrt 2) (- y1 y0))4)) z1))
(setq p2 (list (+ x2 (/ (* (sqrt 2) (- y2 y0)) 4)) (+ y0 (/ (* (sqrt 2) (- y2 y0))4)) z2))
(setq ent (entmod (subst (cons 10 p1)
(assoc 10 ent) ent)))
(entmod (subst (cons 11 p2)
(assoc 11 ent) ent))
(redraw (cdr(assoc -1 ent)) 1))
)
)
)
)
(setvar "CMDECHO" cmdmode)
)
(princ "\n\
tc:V45 loaded.
Start command with V45.")