Jump to content

how to delete block that name is "a"


Arin9916

Recommended Posts

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 o:)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)
)



  • Like 1
Link to comment
Share on other sites

  • 4 months later...
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"

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

  • 3 weeks later...

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

Link to comment
Share on other sites

(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)
)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...