马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- ;;;=======================
- ;;;图块改名.
- ;;;无名块改名后,再改出错.
- ;;;By Aeo
- ;;;-----------------------
- (defun C:TTt ( / blk blkref blocks doc new-blk new-name old-blk old-name)
- (vl-load-com)
- (if(and (setq BLK (car (entsel "\n选要改名的块: ")))
- (setq BLKREF (vlax-ename->vla-object BLK))
- (= (vla-get-objectname BLKREF) "AcDbBlockReference")
- (setq old-name(vla-get-name BLKREF))
- (/= ""(setq new-name(getstring (strcat"\n新名称(" old-name "): "))))
- (not(and(= new-name "*")(princ"\n名称可以为*加任意字母")))
- (not(and(tblsearch "block"new-name)(princ"\n图块已存在.")))
- )
- (progn
- (command"undo""group")
- (setq DOC (vla-get-activedocument (vlax-get-acad-object))
- BLOCKS (vla-get-blocks doc)
- old-blk (vla-item BLOCKS old-name)
- )
- (vla-put-name old-blk new-name)
- (if(wcmatch old-name "`**")
- (progn
- (setq new-BLK (vla-add BLOCKS (vla-get-origin old-blk)new-name))
- (vlax-for ENT old-blk
- (vla-copyobjects DOC
- (vlax-safearray-fill
- (vlax-make-safearray vlax-vbobject '(0 . 0))
- (list ENT)
- )
- new-BLK
- ))
- (vlax-release-object new-BLK)
- )
- )
- (vlax-release-object old-blk)
- (vlax-release-object BLOCKS)
- (vlax-release-object DOC)
- (command"undo""end")
- )
- )
- (prin1)
- )
临时想把块中的一个换个名称:
- ;;;=======================
- ;;;图块改名拷贝,点到的那个块改成新名称,
- ;;;但其他同名块不变.
- ;;;By Aeo
- ;;;-----------------------
- (defun C:TT ( / blk blkref blocks doc new-blk new-name old-blk old-name)
- (vl-load-com)
- (if(and (setq BLK (car (entsel "\n选要改名的块: ")))
- (setq BLKREF (vlax-ename->vla-object BLK))
- (= (vla-get-objectname BLKREF) "AcDbBlockReference")
- (setq old-name(vla-get-name BLKREF))
- (/= ""(setq new-name(getstring (strcat"\n新名称(" old-name "): "))))
- (not(and(= new-name "*")(princ"\n名称可以为*加任意字母,变为匿名块")))
- (not(and(tblsearch "block"new-name)(princ"\n图块已存在.")))
- )
- (progn
- (command"undo""group")
- (setq DOC (vla-get-activedocument (vlax-get-acad-object))
- BLOCKS (vla-get-blocks doc)
- old-blk (vla-item BLOCKS old-name)
- )
- (setq new-BLK (vla-add BLOCKS (vla-get-origin old-blk)new-name))
- (vlax-for ENT old-blk
- (vla-copyobjects DOC
- (vlax-safearray-fill
- (vlax-make-safearray vlax-vbobject '(0 . 0))
- (list ENT)
- )
- new-BLK
- ))
- (vla-put-name BLKREF new-name)
- (vlax-release-object new-BLK)
- (vlax-release-object old-blk)
- (vlax-release-object BLOCKS)
- (vlax-release-object DOC)
- (command"undo""end")
- )
- )
- (prin1)
- )
|