- (defun c:tt(/ bj get-insert-tag&value lm-set-attribute obj ss ss-enlst sx sxlst ty)
- (defun get-insert-Tag&value (blk / lst)
- (if (= (type blk) 'ENAME)
- (if (safearray-value(setq lst (vlax-variant-value(vla-getattributes (vlax-ename->vla-object blk)))))
- (mapcar'(lambda (x)(cons (vla-get-tagstring x) (vla-get-textstring x)))(vlax-safearray->list lst))
- )
- nil
- )
- )
- (defun lm-set-attribute(ty biaoji va / att_list)
- (setq ty (if(=(type ty)'ename)(vlax-ename->vla-object ty)ty))
- (setq att_list (vlax-safeArray->list (vlax-variant-value (vla-getattributes ty))))
- (setq xx(vl-some'(lambda(a)(if(=(strcase(vla-get-TagString a))(strcase biaoji))a))att_list))
- (if xx
- (vla-put-textstring xx va)
- )
- (princ)
- )
- (defun ss-enlst (ss / enlst)
- (cond
- ((= (type ss) 'PICKSET)
- (vl-remove-if-not '(lambda (x) (= (type x) 'ENAME)) (mapcar 'cadr (ssnamex SS)))
- )
- ((= (type ss) 'LIST)
- (setq enlst (ssadd))
- (last (mapcar '(lambda (x) (ssadd x enlst)) ss))
- )
- )
- )
- (defun lm-Get-LwPts(en / x)
- (mapcar
- 'cdr
- (vl-remove-if-not
- '(lambda(x)
- (= (car x) 10)
- )
- (entget en)
- )
- )
- )
- (setq ss(ssget '((0 . "LWPOLYLINE")(8 . "jm-创建块图框"))))
- (foreach ty (ss-enlst ss)
- (setq pts (lm-Get-LwPts ty))
- (setq yss(ssget "cp" pts '((0 . "INSERT")(8 . "图签")(2 . "原始图签"))))
- (if (and yss (> (sslength yss) 0))
- (progn
- (setq
- ty (ssname yss 0)
- obj(vlax-ename->vla-object ty)
- sxlst (get-insert-Tag&value ty)
- )
- (entdel ty)
- (setq xss(ssget "cp" pts '((0 . "INSERT")(2 . "新图签"))))
- (foreach ty (vl-remove-if-not '(lambda (x) (= (type x) 'ENAME)) (mapcar 'cadr (ssnamex xss)))
- (foreach x sxlst
- (setq
- bj(car x)
- sx(cdr x)
- )
- (lm-set-attribute ty bj sx)
- )
- )
- )
- )
- )
- (princ)
- )
|