pixel8er Posted April 4, 2018 Share Posted April 4, 2018 (edited) Hi everyone This simple script to select and delete the COS_DWGS_STATUS dynamic block from a series of drawings is not working. Any ideas? (command "erase" (SSGET "X" '((0 . "INSERT") (2 . "COS_DWGS_STATUS" ))) "") Thanks Paul Edited April 4, 2018 by pixel8er Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 4, 2018 Share Posted April 4, 2018 Worked for me just used a different block name to test maybe you have a space in block name on end. Quote Link to comment Share on other sites More sharing options...
pixel8er Posted April 4, 2018 Author Share Posted April 4, 2018 No space in the name. The block is dynamic - does that make any difference? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 5, 2018 Share Posted April 5, 2018 You will need to check for dynamic block a block and dynamic has 2 names you can look at dynamic block EffectiveName (RO) = "bolt" Name = "*U200" std block EffectiveName (RO) = "NORTHN" Name = "NORTHN" This has no error checking and will delete all. (defun delblock ( / ss x) (setq ss (SSGET "X" '((0 . "INSERT")))) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (if (= (vla-get-EffectiveName obj) "COS_DWGS_STATUS") (vla-delete obj) ) ) (princ) ) (delblk) Quote Link to comment Share on other sites More sharing options...
pixel8er Posted April 5, 2018 Author Share Posted April 5, 2018 Thanks BIGAL, Champion! That worked perfectly. Just needed to adjust the function definition. This has no error checking and will delete all. (defun delbl[b][color="red"]oc[/color][/b]k ( / ss x) (setq ss (SSGET "X" '((0 . "INSERT")))) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (if (= (vla-get-EffectiveName obj) "COS_DWGS_STATUS") (vla-delete obj) ) ) (princ) ) (delblk) Quote Link to comment Share on other sites More sharing options...
pixel8er Posted April 5, 2018 Author Share Posted April 5, 2018 That's a very handy tip about the two names for dynamic blocks Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 6, 2018 Share Posted April 6, 2018 (edited) Dont forget the last one or make a C:delblock Me personally pick the block get its effective name then run the code no need for hard coded block name. Error check added to make sure it was a block. (defun delblock ( / ss x effname) (if (and (setq obj (vlax-ename->vla-object (car (entsel "\nPick block/s to delete ")))) (= (vla-get-objectname obj) "AcDbBlockReference") ) (progn (setq effname (vla-get-EffectiveName obj)) (setq ss (SSGET "X" '((0 . "INSERT")))) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (if (= (vla-get-EffectiveName obj) effname) (vla-delete obj) ) ) ) (alert "you did not pick a block") ) (princ) ) (delblock) Edited April 6, 2018 by BIGAL 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.