“-BEdit”多块
大家好!拜托,有人能帮我吗?我用下面的LISP来编辑块,删除实体和图案填充,但我需要逐个单击。
我想做一个窗口选择,然后LISP编辑一个一个单独。
(defun C:Clean()
(vl-load-com)
(cond ((and (setq ent (car (entsel "\nSelecione o Bloco: ")))
(eq (cdr (assoc 0 (entget ent))) "INSERT")
(setq NAME (vla-get-effectivename(vlax-ename->vla-object ent))))))
(command "-bedit" NAME)
(setq HT (ssget "all" '((0 . "HATCH"))))
(command "erase" HT "")
(setq SS (ssget "all" '((0 . "SOLID"))))
(command "erase" SS "")
(command "chprop" "all" "" "Color" "bylayer" "")
(command "bclose" "S")
(princ)
)
谢谢 请阅读代码发布指南并编辑您的帖子,将代码包含在代码标签中。 一些建议可能会放大每个块或图案填充,并要求删除是/否作为是使用任何键作为否。您只需要使用以下示例代码。这还不完整。
(sslength ht) ; this tells you how many objects
(repeat (sslength ht)) ;a loop that goes through all the object in the selection set
(ssname ht x) ; this retrieves the object based on the value of x start at 0
(command "erase" (ssname ht x) "") ; removes object
(entget (ssname ht 2)) ; look at 2nd object in HT use this for zooming etc
感谢您的回复BIGAL,
但我不明白我可以把这些代码放在哪里。。。。
例如,客户端向我发送了一个包含许多块的文件,其中块内有实体和阴影,我需要删除所有块内的所有实体和阴影。。。 未测试,但请尝试:
(defun C:Clean ( / bl ss i ent name h s )
(vl-load-com)
(setq bl (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
(while (not ss)
(if (setq ss (ssget "_:L" '((0 . "INSERT"))))
(progn
(setq i -1)
(while (setq ent (ssname ss (setq i (1+ i))))
(setq name (vla-get-effectivename (vlax-ename->vla-object ent)))
(if (eq (vla-get-isxref (vla-item bl name)) :vlax-false)
(progn
(command "_.bedit" name)
(setq h (ssget "all" '((0 . "HATCH"))))
(command "_.erase" h "")
(setq s (ssget "all" '((0 . "SOLID"))))
(command "_.erase" s "")
(command "_.chprop" "all" "" "Color" "ByLayer" "")
(command "_.bclose" "S")
)
)
)
)
(prompt "\nEmpty sel.set... Select again...")
)
)
(princ)
)
此外,由Tharwat(更新为包括“SOLID”)
http://www.cadtutor.net/forum/showthread.php?80180-从块中删除图案填充
(vl-load-com)
(defun c:Test (/ b o)
;;--- Tharwat 26.June.2013 ---;;
(or doc
(setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
)
(vlax-for b
(vla-get-blocks
doc
)
(if (and
(eq :vlax-false (vla-get-isLayout b))
(eq :vlax-false (vla-get-isXref b))
)
(vlax-for o b
(if (or
(eq "AcDbHatch" (vla-get-objectname o))
(eq "AcDbSolid" (vla-get-objectname o))
)
(vl-catch-all-apply 'vla-delete (list o))
)
)
)
)
(vla-regen doc acAllViewports)
(princ)
)
谢谢Marko_ribar。。。这可以工作,但编辑图形中的所有块(大约1500个)包括没有图案填充和实体的块,并得到“内部错误”并关闭AutoCad。(我的失败无法更好地解释)
总成_
这件作品太棒了!谢谢 编辑块也可以更改“BYLAYER”的颜色?
添加
................
................
(vlax-for o b
(if (or
(eq "AcDbHatch" (vla-get-objectname o))
(eq "AcDbSolid" (vla-get-objectname o))
)
(vl-catch-all-apply 'vla-delete (list o))
(vla-put-color o "256")
)
)
................
................
试试这个。。。
(vl-load-com)
(defun c:Test (/ b o)
;;--- Tharwat 2014 ---;;
(or doc (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))))
(vlax-for b (vla-get-blocks doc )
(if
(and
(eq :vlax-false (vla-get-isLayout b))
(eq :vlax-false (vla-get-isXref b))
)
(vlax-for o b
(if (or
(eq "AcDbHatch" (vla-get-objectname o))
(eq "AcDbSolid" (vla-get-objectname o))
)
(vl-catch-all-apply 'vla-delete (list o))
(vl-catch-all-apply 'vla-put-color (list o AcBylayer))
)
)
)
)
(vla-regen doc acAllViewports)
(princ)
)
页:
[1]
2