ecustis Posted November 7, 2017 Share Posted November 7, 2017 Hello all, I need to select two blocks and delete them automatically, their names are: FA_DEVICE_INIT_BASE_STANDARD and FA_DEVICE_INIT_SMOKE_DUCT_HOUSING I usually use the quick select tool to delete these because they're always grouped with the actual device block. For example, we would have a smoke detector block and then it would have a "base" block underneath of it grouped with it so when we did exports they would be on the counts. When using quick select, if I say select block by name "FA_DEVICE_INIT_BASE_STANDARD" it actually only selects that block and not the "FA_DEVICE_INIT_SMOKE" block that is grouped with it. Is there any way to replicate what quick select does with autolisp? Here is what I have so far, it currently selects the blocks but it also selects any associated groups and deletes them too: (defun c:AutoBlkRepPrepare () (if (setq ss1 (ssget "_x" '((0 . "INSERT")(2 . "FA_DEVICE_INIT_BASE_STANDARD,FA_DEVICE_INIT_SMOKE_DUCT_HOUSING")))) (progn (command "_.erase" ss1) ) (alert "No preparation necessary!") ) (princ) ) Any help with this is greatly appreciated! Thanks! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 8, 2017 Share Posted November 8, 2017 You will need to check somehow if its a group, something I dont use very often. An idea may be get all the groups check for your blocks in group make a list of all objects, ungroup delete blocks then regroup remainder. Then run what you have to get rid of individuals. Really need a sample dwg. Some one other than me may have some GROUP code that would be usefull. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted November 8, 2017 Share Posted November 8, 2017 You can temporarily change the PICKSTYLE. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 8, 2017 Share Posted November 8, 2017 Cool Roy_043 tried it out. Quote Link to comment Share on other sites More sharing options...
ecustis Posted November 9, 2017 Author Share Posted November 9, 2017 You can temporarily change the PICKSTYLE. Thanks Roy, I added a pickstyle change to the code and it works now. The only thing that happens is it says "; error: Function cancelled". It doesn't affect the process and all and everything still works, but it is just annoying that it won't print the text I want it to. Here is the updated code: (defun c:AutoBlkRepPrepare () (command "pickstyle" "0") (if (setq ss1 (ssget "_x" '((0 . "INSERT")(2 . "FA_DEVICE_INIT_BASE_STANDARD,FA_DEVICE_INIT_SMOKE_DUCT_HOUSING")))) (progn (command "_.erase" ss1) ) (alert "No preparation necessary!") ) (command "pickstyle" "1") (princ "Preparation complete!") (princ) ) Anyone have any suggestions on how to get rid of that error? Thanks! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 9, 2017 Share Posted November 9, 2017 (edited) Try this .. removed command calls. (defun c:foo (/ ps s) ;<- Localize variables (setq ps (getvar 'pickstyle)) (setvar 'pickstyle 0) (if (setq s (ssget "_x" '((0 . "INSERT")))) (mapcar 'entdel (mapcar 'cadr (ssnamex s))) (alert "No preparation necessary!") ) (setvar 'pickstyle ps) (princ) ) Edited November 9, 2017 by ronjonp Quote Link to comment Share on other sites More sharing options...
ecustis Posted November 9, 2017 Author Share Posted November 9, 2017 Try this .. removed command calls. (defun c:autoblkrepprepare (/ ps s) ;<- Localize variables (setq ps (getvar 'pickstyle)) (setvar 'pickstyle 0) (if (setq s (ssget "_x" '((0 . "INSERT") (2 . "FA_DEVICE_INIT_BASE_STANDARD,FA_DEVICE_INIT_SMOKE_DUCT_HOUSING")) ) ) (mapcar 'entdel (mapcar 'cadr (ssnamex s))) (alert "No preparation necessary!") ) (setvar 'pickstyle ps) (princ) ) Ron, this is awesome, works like a charm! Now to look up and learn what all you did so I can make my code not so basic. Thank you very much! Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 9, 2017 Share Posted November 9, 2017 Ron, this is awesome, works like a charm! Now to look up and learn what all you did so I can make my code not so basic. Thank you very much! Glad to help 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.