谢谢你,米尔恰,效果很好。
我注意到我的大于/小于错误!
- (defun c:levbnd ()
- ;ask for lower and upper bounds
- (setq lower (getreal "\nLower bound...?"))
- (setq upper (getreal "\nUpper bound...?"))
- ;select text objects to be evaluated
- (setq ss (ssget '((0 . "TEXT"))))
- (setq l (sslength ss))
- (setq c 0)
- ;evaluate each text object
- (while (/= c l)
- (setq ent (ssname ss c))
- (setq elist (entget ent))
- (setq txt (cdr (assoc 1 elist)))
- (setq val (atof txt))
- ;if value lower than the lower bound
- (if (< val lower )
- ;then change text object colour to red
- (entmod (if (assoc 62 elist)
- (subst '(62 . 1) (assoc 62 elist) elist)
- (cons '(62 . 1) elist)))
- ;else, is it higher than the upper bound?
- (if (> val upper )
- ;then change text object colour to red
- (entmod (if (assoc 62 elist)
- (subst '(62 . 1) (assoc 62 elist) elist)
- (cons '(62 . 1) elist)))
- )
- )
- (setq c (+ 1 c))
- )
- )
|