Marcelo Marani Posted January 29, 2014 Share Posted January 29, 2014 (edited) Hi all! Please, someone can help me with this? I make this following LISP for edit a block and erase solids and hatch, but I need click one by one. I want make a window selection and then the LISP edit one by one alone. (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) ) Thanks! Edited January 29, 2014 by Marcelo Marani Quote Link to comment Share on other sites More sharing options...
SLW210 Posted January 29, 2014 Share Posted January 29, 2014 Please read the Code posting guidelines and edit your post to include the Code in Code Tags. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 29, 2014 Share Posted January 29, 2014 A few suggestions maybe zoom in on each block or hatch and ask delete yes /no use as a yes any key as a no. You just need to use the following example code. This is not complete. (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 Quote Link to comment Share on other sites More sharing options...
Marcelo Marani Posted January 30, 2014 Author Share Posted January 30, 2014 Thanks for reply BIGAL, but I dont understand where I can place this codes.... For example, the client send me a file with many blocks with solids and hatchs inside of the block, and I need erase all solids and hatchs inside off all blocks... Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted January 30, 2014 Share Posted January 30, 2014 Not tested, but try: (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) ) Quote Link to comment Share on other sites More sharing options...
GP_ Posted January 30, 2014 Share Posted January 30, 2014 Also this, by Tharwat (updated to include "SOLID") http://www.cadtutor.net/forum/showthread.php?80180-Deleting-Hatch-from-Blocks (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 [b][color=red](or[/color][/b] (eq "AcDbHatch" (vla-get-objectname o)) [b][color=red](eq "AcDbSolid" (vla-get-objectname o))[/color][/b] [b][color=red] )[/color][/b] (vl-catch-all-apply 'vla-delete (list o)) ) ) ) ) (vla-regen doc acAllViewports) (princ) ) Quote Link to comment Share on other sites More sharing options...
Marcelo Marani Posted January 30, 2014 Author Share Posted January 30, 2014 marko_ribarNot tested, but try: Thanks Marko_ribar... this works but edit all blocks in the drawing (around 1500) include block without hatchs and solids and get a "INTERNAL ERROR" and close AutoCad. (my fail dont explain better) GP_Also this, by Tharwat (updated to include "SOLID") http://www.cadtutor.net/forum/showth...ch-from-Blocks GP_ This work perfect! Thanks! Quote Link to comment Share on other sites More sharing options...
Marcelo Marani Posted January 30, 2014 Author Share Posted January 30, 2014 For edit blocks to change colors for "BYLAYER" is possible too? Quote Link to comment Share on other sites More sharing options...
GP_ Posted January 30, 2014 Share Posted January 30, 2014 For edit blocks to change colors for "BYLAYER" is possible too? Add... [color=slategray]................[/color] [color=slategray]................[/color] [color=slategray](vlax-for o b[/color] [color=slategray] (if (or[/color] [color=slategray] (eq "AcDbHatch" (vla-get-objectname o))[/color] [color=slategray] (eq "AcDbSolid" (vla-get-objectname o))[/color] [color=slategray] )[/color] [color=slategray] (vl-catch-all-apply 'vla-delete (list o))[/color] [color=red][b](vla-put-color o "256")[/b][/color] [color=slategray] )[/color] [color=slategray])[/color] [color=slategray]................[/color] [color=slategray]................[/color] Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 30, 2014 Share Posted January 30, 2014 For edit blocks to change colors for "BYLAYER" is possible too? Try this one ... (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) ) Quote Link to comment Share on other sites More sharing options...
Marcelo Marani Posted January 31, 2014 Author Share Posted January 31, 2014 Thanks! Work Perfect and very fast! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 31, 2014 Share Posted January 31, 2014 Thanks! Work Perfect and very fast! Excellent , you are welcome . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.