怎么批量把---动态块转普通块-------------急用,谢了。
怎么批量把---动态块转普通块-------------高手帮看看,感谢 4楼代码整复杂了,更简单的代码:;;动态块改为普通快 By Gu_xl 2013.11.13
(defun c:DynBlk2blk (/ cnt)
(if (ssget (list '(0 . "INSERT") (cons 410 (getvar 'CTAB))))
(progn
(setq cnt 0)
(vlax-for obj
(vla-get-activeselectionset
(vla-get-activedocument (vlax-get-acad-object))
)
(if (and
(vlax-property-available-p obj 'isdynamicblock)
(eq :vlax-true (vla-get-isdynamicblock obj))
)
(progn
(setq cnt (1+ cnt))
(vla-ConvertToAnonymousBlock obj)
)
)
)
(princ (strcat "\n***共修改 " (itoa cnt) " 个动态块***"))
)
)
(princ)
) ;;动态块转为普通块
(defun c:XXdyn (/ actDoc)
(vl-load-com)
(setq actDoc (vla-get-ActiveDocument (vlax-get-acad-object))
) ;_ end_setq
(vla-startundomark actDoc)
(foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget "x" '((0 . "INSERT")))))) ;_ end_vl-remove-if
(if (equal (vla-get-IsDynamicBlock (vlax-ename->vla-object x)) :vlax-true) ;_ end_equal
(vla-ConvertToAnonymousBlock (vlax-ename->vla-object x))) ;_ end_if
) ;_ end_foreach
(vla-endundomark actDoc)
(princ)
) ;_ end_defun
之前找到个类似的,不知道是否一样的版本。 没下载附件
思路:炸开 ---> 重建 --> 循环 emk 发表于 2013-11-12 18:24 static/image/common/back.gif
没下载附件
思路:炸开 ---> 重建 --> 循环
场景动态块太多。。炸开不现实
;;动态块改为普通快 By Gu_xl 2013.11.13
(defun c:DynBlk2blk (/ lst name blkdef blkref cnt)
(if (ssget (list '(0 . "INSERT") (cons 410 (getvar 'CTAB))))
(progn
(setq cnt 0)
(vlax-for obj
(vla-get-activeselectionset
(vla-get-activedocument (vlax-get-acad-object))
)
(if (and
(vlax-property-available-p obj 'isdynamicblock)
(eq :vlax-true (vla-get-isdynamicblock obj))
)
(progn
(setq lst nil
cnt (1+ cnt)
)
(vlax-for a (vla-item (vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(vla-get-name obj)
)
(setq lst (cons a lst))
)
(setq blkdef
(vla-add
(vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
(vlax-3d-point '(0 0 0))
"*U"
)
)
(vla-CopyObjects
(vla-get-activedocument (vlax-get-acad-object))
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbobject
(cons 0 (1- (length lst)))
)
lst
)
)
blkdef
)
(setq name (vla-get-name blkdef))
(setq blkref
(vla-InsertBlock
(vlax-get-property
(vla-get-activedocument (vlax-get-acad-object))
(if (= 1 (getvar 'CVPORT))
'PaperSpace
'ModelSpace
)
)
(vla-get-InsertionPoint obj)
Name
(vla-get-XScaleFactor obj)
(vla-get-YScaleFactor obj)
(vla-get-ZScaleFactor obj)
(vla-get-Rotation obj)
)
)
(vla-put-layer blkref (vla-get-layer obj))
(vla-delete obj)
)
)
)
(princ (strcat "\n***共修改 " (itoa cnt) " 个动态块***"))
)
)
(princ)
) 这个程序好,我要用到,我是一个一个炸了后再做的,累啊 楼主好代码啊,顶上一个 Gu_xl 发表于 2013-11-13 19:07 static/image/common/back.gif
4楼代码整复杂了,更简单的代码:
感谢源码分享 好代码,学习一下喽 Gu_xl 发表于 2013-11-13 19:07 static/image/common/back.gif
4楼代码整复杂了,更简单的代码:
感谢版主回复。。。。才忙完上论坛。。