本帖最后由 鱼与熊掌 于 2015-1-19 00:47 编辑
;跟帖伪源码.
;上方演示图的伪源码.
;另外为替换文字函数的函数,支持属性块.
;函数Etype,Dxf,entmod,借用一部分E派函数. - ;功能,索引加
- (defun c:jsy (/ *cx_jsyint attlst minx slst ss)
- ;;; (setq ss (ssget ))
- (if (null *cx_jsyint)
- (setq *cx_jsyint 1)
- )
- (while (progn
- (setq ss
- (cx-ssget (strcat "选择递增块,起始值:" (itoa *cx_jsyint) "\n")
- (CX-LST+STR (CX-RANGE-STRNUM 1 100) " ")
- '((0 . "INSERT"))
- )
- )
- (cond
- ((=
- 'str
- (type ss)
- )
- (setq *cx_jsyint (atoi ss))
- t
- )
- (ss
- nil
- )
- (t t)
- )
- )
- )
- (if ss
- (progn
- (setq slst (cx-ss2en ss))
- (setq attlst (mapcar '(lambda (x) (cx-Get-Attstr x)) slst))
- (setq attlst (apply 'append attlst))
- (setq attlst (VL-REMOVE-IF-NOT 'CX-STRISINT attlst))
- (setq attlst (mapcar 'atoi attlst))
- (setq minx (apply 'min attlst))
- (cx-reptext
- slst
- (CX-RANGE-STRNUM minx (+ minx 3))
- (CX-RANGE-STRNUM *cx_jsyint (+ *cx_jsyint 3))
- )
- (setq *cx_jsyint (+ 4 *cx_jsyint))
- )
- )
- )
- ;批量替换文本.
- (defun CX-reptext (SS oldch newch / ct0 ct1
- ct2 edata etext newtext obj readch
- schct ssl subln txtln
- )
- (if (/= 'list (type ss))
- (setq ss (cx-ss2en ss))
- )
- (foreach x ss
- (cond
- ((cx-Etype x "*TEXT")
- (cx-entmod x 1 (cx-str-th newch oldch (cx-dxf 1 x)))
- )
- ((cx-Etype x "INSERT")
- (setq obj (zvla x))
- (mapcar '(lambda (att)
- ;(cons (vla-get-TagString att) (vla-get-TextString att))
- (vla-put-TextString
- att
- (cx-str-th newch
- oldch
- (vla-get-TextString
- att
- )
- )
- )
-
-
- )
- (vlax-invoke obj "GetAttributes")
- )
- )
- )
- )
- )
|