Arin9916 Posted June 15, 2011 Posted June 15, 2011 hi! i use like this (ssget "x" '((2 . "a")))... but i can`t select block in block.. i want delete "a" block block in block. maybe block in block in block... please help Quote
dbroada Posted June 15, 2011 Posted June 15, 2011 I'm not sure I understand what you are trying to do here. I assume you are trying to purge that block from the drawing. Yoiu won't be able to do that until you have removed all instances of it from the block definitions. This is far beyond my LISP knowledge but I think you will have to step through each block definition and remove it from there until before it can be removed totally. Quote
Arin9916 Posted June 15, 2011 Author Posted June 15, 2011 thanks dbroada. and sorry i`m not good english . here is my answer i found google. (defun PTE:del-block (bname / bobj) (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (= bname (vla-get-name blk)) (setq bObj blk) (progn (vlax-for ent blk (if (and (= "AcDbBlockReference" (vla-get-objectname ent)) (or (= (vla-get-name ent) bname) (and (vlax-property-available-p ent 'effectivename) (= (vla-get-effectivename ent) bname) ) ) ) (vla-delete ent) ) ) ) ) ) (if bObj (vla-delete bObj)) (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports) ) 1 Quote
designerstuart Posted November 14, 2011 Posted November 14, 2011 i don't understand - what command do you use to run this script? Quote
Tharwat Posted November 14, 2011 Posted November 14, 2011 i don't understand - what command do you use to run this script? Hope that Arin do not mind . After loading the code and another line to implement the code . e.g if you have a block called :metal and you want to delete it from your current drawing . (PTE:del-block "metal" Quote
Lee Mac Posted November 14, 2011 Posted November 14, 2011 i don't understand - what command do you use to run this script? The function in post#3 (not script - a script is something entirely different) requires a single argument (or parameter), whose value will be bound to the 'bname' symbol. Just as the 'getpoint' function, for example, will accept two arguments (or parameters): a string to prompt the user and a basepoint: ([font=Georgia][color=blue][i]getpoint [/i][/color][/font][[font=Courier New][color=darkred]pt[/color][/font]] [[font=Courier New][color=darkred]string[/color][/font]]) the function: 'PTE:del-block' requires a single argument - the block name: ([font=Georgia][color=blue][i]PTE:del-block[/i][/color][/font] [[font=Courier New][color=darkred]bname[/color][/font]]) Hence it could be called from another program: (defun c:test ( / str ) (setq str (getstring "\nSpecify Block to Delete: ")) (if (tblsearch "BLOCK" str) ([font=Georgia][color=blue][i]PTE:del-block[/i][/color][/font] str) (princ "\nBlock doesn't Exist.") ) (princ) ) Quote
stevesfr Posted December 5, 2011 Posted December 5, 2011 I tried combining the two programs; doesn't work for me. (defun c:Del-block ( / str ) (defun PTE:del-block (bname / bobj) (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (= bname (vla-get-name blk)) (setq bObj blk) (progn (vlax-for ent blk (if (and (= "AcDbBlockReference" (vla-get-objectname ent)) (or (= (vla-get-name ent) bname) (and (vlax-property-available-p ent 'effectivename) (= (vla-get-effectivename ent) bname) ) ) ) (vla-delete ent) ) ) ) ) ) (setq str (getstring "\nSpecify Block to Delete: ")) (if (tblsearch "BLOCK" str) (PTE:del-block str) (princ "\nBlock doesn't Exist.") ) (princ) ) what am I doing wrong? thx Quote
alanjt Posted December 5, 2011 Posted December 5, 2011 (defun c:test (/ PTE:del-block str) (defun PTE:del-block (bname / bobj) (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (= bname (vla-get-name blk)) (setq bObj blk) (progn (vlax-for ent blk (if (and (= "AcDbBlockReference" (vla-get-objectname ent)) (or (= (vla-get-name ent) bname) (and (vlax-property-available-p ent 'effectivename) (= (vla-get-effectivename ent) bname) ) ) ) (vla-delete ent) ) ) ) ) ) (if bObj (vla-delete bObj) ) (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports) ) (setq str (getstring T "\nSpecify Block to Delete: ")) (if (tblsearch "BLOCK" str) (PTE:del-block str) (princ "\nBlock doesn't Exist.") ) (princ) ) Quote
stevesfr Posted December 5, 2011 Posted December 5, 2011 Thanks Alan... learning slow but sure... Steve Quote
alanjt Posted December 5, 2011 Posted December 5, 2011 Thanks Alan... learning slow but sure...Steve You're welcome. I also added a "T" to the getstring function within Lee's bit to allow for blocks with spaces in the name. Quote
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.