运行SZFW,运行后达到图片的功能。下面的代码可以找出普通数值的大值,但如果最大值在中部或者在尾部,则不行。请大虾帮改一下。
- (defun c:szfw(/ r_min r_max co ss n en ent s)
- (setq layer_bk (getvar "clayer"))
- (setvar "cmdecho" 0)
- (setq osmode_backup (getvar "osmode"))
- (setvar "OSMODE" 0)
-
- (if (setq r_min (getreal "\n请输入变色改层数字下限(不包含)<1.1>:")) nil (setq r_min 1.1))
- (if (setq r_max (getreal "\n请输入变色改层数字上限(不包含)<9.99>:")) nil (setq r_max 9.99))
-
- (setq co (acad_colordlg 1))
- ;-----------------------------------------------------------------------------
- (if (= (tblobjname "LAYER" "JGLS-1临时图层") nil)
- (progn
- (entmake (list
- '(0 . "LAYER")
- '(100 . "AcDbSymbolTableRecord")
- '(100 . "AcDbLayerTableRecord")
- '(6 . "CONTINUOUS")
- '(62 . 1)
- '(70 . 0)
- (cons 2 "JGLS-1临时图层")
- )
- )
- )
- )
- (setvar "clayer" "JGLS-1临时图层")
- (command "color" "bylayer")
- ;-----------------------------------------------------------------------------
- (setq ss (ssget '((0 . "TEXT")(-4 . "<AND")(1 . "~*[~!-~]*")(1 . "~*@*")(1 . "*#*")(-4 . "AND>"))))
- (repeat (setq n (sslength ss))
- (setq en (ssname ss (setq n (1- n))))
- (setq ent (entget en))
- (setq s (atof (cdr (assoc 1 ent))))
- (if (and (> s r_min) (< s r_max))
-
- (if (assoc 8 ent) (setq ent (subst (cons 8 "JGLS-1临时图层") (assoc 8 ent) ent))
- (setq ent (cons (cons 8 "JGLS-1临时图层") ent))
- ) ;end if 1
-
- ) ;end if 2
- (if (and (> s r_min) (< s r_max))
-
- (if (assoc 62 ent) (setq ent (subst (cons 62 co) (assoc 62 ent) ent))
- (setq ent (cons (cons 62 co) ent))
- ) ;end if 1
-
- ) ;end if 2
- (entmod ent)
-
- ) ;end repeat
- (setvar "clayer" layer_bk)
- (setvar "OSMODE" osmode_backup)
-
- (princ)
- )
|