- (defun $block-rename$ (ent oldname newname lst / blocks blk rename obj)
- ;修改块名
- (if (not oldname)
- (if ent
- (progn
- (if (= (TYPE ent) 'ENAME)
- (SETQ OBJ (vlax-ename->vla-object ent))
- )
- (setq oldname (vl-catch-all-apply
- 'vla-get-effectivename
- (list obj)
- )
- )
- (if (vl-catch-all-error-p oldname)
- (setq oldname (vl-catch-all-apply 'vla-get-name (list obj)))
- )
- (if (vl-catch-all-error-p oldname)
- (setq oldname nil)
- )
- )
- )
- )
- (if newname
- (progn
- (setq blocks (vla-get-blocks
- (vla-get-activeDocument (vlax-get-acad-object))
- )
- )
- (setq blk (vl-catch-all-apply 'vla-item (list blocks oldname)))
- (vl-catch-all-apply 'vla-put-name (list blk newname))
- (setq rename (vla-get-name blk))
- (vl-catch-all-apply 'vlax-release-object (list blocks))
- (vl-catch-all-apply 'vlax-release-object (list blK))
- )
- )
- rename ;返回
- )
|