这段代码可以使用楼主演示的第一张图
- (defun c:cj()
- (setvar "cmdecho" 0)
- (setq selnum (getvar "osmode"))
- (setvar "osmode" 0)
- (setq cly (getvar "clayer"))
- (setq tb (tblsearch "LAYER" "ZTEMP"))
- (if (= tb nil)(command "layer" "m" "ZTEMP" "c" 7 "ZTEMP" ""))
- (setq tb (tblsearch "LAYER" "ZZTEMP"))
- (if (= tb nil)(command "layer" "m" "ZZTEMP" "c" 7 "ZZTEMP" ""))
- (setq p1 (getpoint "\nFirst corner:"))
- (setq p2 (getcorner p1 "\nSecond corner:"))
- (setq ss (ssget "c" p1 p2 '((0 . "LINE"))))
- (setq ename (ssname ss 0))
- (setq endata (entget ename))
- (setq oldlay (cdr (assoc 8 endata)))
- (command "chprop" ss "" "la" "ZTEMP" "")
-
- (if (= (sslength ss) 4)
- (progn
- (setq i 0)
- (repeat (sslength ss)
- (setq ename (ssname ss i))
- (command "chprop" ename "" "la" "ZZTEMP" "")
- (setq endata (entget ename))
- (setq pt1 (cdr (assoc 10 endata)))
- (setq pt2 (cdr (assoc 11 endata)))
-
- (setq ppf (list pt1 pt2))
- (setq ssk (ssget "F" ppf))
- (setq ssp (ssget "P" '((8 . "ZTEMP"))))
- ;(print (sslength SSP))
- (if (= (sslength ssp) 2)
- (progn
- (setq enamel (ssname ssp 0))
- (setq endata (entget enamel))
- (setq ptr11 (cdr (assoc 10 endata)))
- (setq ptr12 (cdr (assoc 11 endata)))
- (setq ptrim1 (inters pt1 pt2 ptr11 ptr12 nil))
- (setq enamel (ssname ssp 1))
- (setq endata (entget enamel))
- (setq ptr21 (cdr (assoc 10 endata)))
- (setq ptr22 (cdr (assoc 11 endata)))
- (setq ptrim2 (inters pt1 pt2 ptr21 ptr22 nil))
- (command "break" ename ptrim1 ptrim2)
- (setq ssz (ssget "X" '((8 . "ZZTEMP"))))
- (command "chprop" ssz "" "la" "ZTEMP" "")
- )
- )
- (setq i (+ i 1))
-
- )
-
- )
- )
- (setq ssz (ssget "X" '((8 . "ZTEMP"))))
- (command "chprop" ssz "" "la" oldlay "")
- (setvar "osmode" selnum)
- (setvar "clayer" cly)
- (prin1)
- )
- (prin1)
|