写了一下,你看看:
-
- (if (not olderr)
- (setq olderr *error*)
- )
- (defun *error* (msg)
- (setq en (getvar "errno"))
- (setq errmsg (strcat "errno=" (itoa en) "\nError:" msg))
- (alert errmsg)
- (setq *error* olderr)
- )
- (defun getcolor()
- (if (not c)
- (setq c 1)
- (progn
- (if (< c 7)
- (setq c (1+ c))
- (setq c 1)
- )
- )
- )
- )
- (defun setcolor(sname color / sinf)
- (setq sinf (entget sname))
- (if (assoc 62 sinf)
- (setq sinf (subst (cons 62 color) (assoc 62 sinf) sinf))
- (setq sinf (append sinf (list (cons 62 color))))
- )
- (entmod sinf)
- )
- (defun getinterLine(entMother entLine / ent pt1 pt2 ss n i entList)
- (ssadd entLine ssAll)
- (setq ent (entget entLine))
- (setq pt1 (cdr (assoc 10 ent)))
- (setq pt2 (cdr (assoc 11 ent)))
- (setq ss (ssget "f" (list pt1 pt2) '((0 . "LINE"))))
- (if entMother (ssdel entMother ss))
- (ssdel entLine ss)
- (setq n (sslength ss))
- (setq i 0)
- (while (< i n)
- (setq entList (append entList (list (ssname ss i))))
- (setq i (1+ i))
- )
- (setq ss nil)
- (setq i 0)
- (repeat n
- (if (not (ssmemb (setq ent (nth i entList)) ssAll))
- (getinterLine entLine ent)
- )
- (setq i (1+ i))
- )
- ssAll
- )
- (defun c:main( / ent i)
- (setq ent (car (entsel "Select the Line...")))
- (if (/= (cdr (assoc 0 (entget ent))) "LINE")
- (exit)
- )
- (setq ssall (ssadd))
- (Getinterline nil ent)
- (setq i 0)
- (setq c (getcolor))
- (setcolor ent c)
- (repeat (sslength ssAll)
- (setcolor (ssname ssAll i) c)
- (setq i (1+ i))
- )
- (setq ssAll nil)
- (setq *error* olderr)
- (princ)
- )
-
|