- (setq ss (ssget ":E:S" '((0 . "INSERT")))) ;;;选择图块
- (setq ent (vlax-ename->vla-object (ssname ss 0))) ;;;转换成VLA对象
- (setq blkname (vla-get-name ent)) ;;;获取图块名
- (setq doc1 (vla-get-ActiveDocument (vlax-get-acad-object))) ;;;获取当前文档
- (setq blk1 (vla-item (vla-get-blocks doc1) blkname)) ;;;获取当前图块定义blk1
- (setq doc2 (vla-item (vla-get-Documents (vlax-get-acad-object)) "Drawing2.dwg")) ;;;获取需要更新的文档
- (setq blk2 (vla-item (vla-get-blocks doc2) blkname)) ;;;获取需要更新的图块定义blk2
- (vlax-for item blk2 (vla-delete item)) ;;;删除图块定义blk2中的图元
- (setq listblk '())
- (vlax-for item blk1 (setq listblk (cons item listblk))) ;;;把blk1中的图元列表
- (setq saf (vlax-make-safearray vlax-vbObject (cons 0 (1- (length listblk)))))
- (vlax-safearray-fill saf listblk) ;;;把列表转成数组
- (vla-CopyObjects doc1 saf blk2) ;;;把数字复制到blk2中
- (vla-Regen doc2 acActiveViewport) ;;;刷新doc2
|