Jump to content

how do you select a block by name?


designerstuart

Recommended Posts

i want to do smething like:

select

[enter block name]

erase

is there a way to do this? i'll use it as part of a script. any way to delete all instances of a block without having to click it would be great.

 

thanks!

Link to comment
Share on other sites

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • designerstuart

    7

  • BIGAL

    3

  • ScribbleJ

    3

  • CADEveryDay

    3

a bit more info:

i've tried using qselect, but can't run it from the command line. i've tried SELECT and ERASE commands, but neither seem to have the ability to chose objects by name? closest i've come is by using the 'previous' bit of a command, but not close enough. thx!

Link to comment
Share on other sites

Thanks Tiger

 

"QSELECT does not have command line option" - oh dear, as i suspected.

 

i was hoping to avoid lisp - mainly because i was hoping it could be done from the command line.

is there really no way to select or delete a block by name without lisping?

Link to comment
Share on other sites

I ain't the brightest star when it comes to scripting, but I know that you can use the SSGT function right on the comandline - shouldn't that mean it's possible to put it into a script?

Link to comment
Share on other sites

hmmm i'm afraid i don't know enough about that either.......

 

failing that, anyone know a way to insert the block definition into a drawing, but not the block itself? above i was trying to insert a block, then delete it in a script, but if i can not insert it in the first place that would work.

 

thanks!

Link to comment
Share on other sites

as I can never remember how to escape from scripts I do it this way....

 

INSERT
myBLOCK
0,0
<etc>
ZOOM
E
ERASE
L

ZOOM
P

 

you may not need the zoom commands provided you drop the block within the visible area of your drawing.

Link to comment
Share on other sites

as I can never remember how to escape from scripts I do it this way....

 

.......

 

you may not need the zoom commands provided you drop the block within the visible area of your drawing.

 

great dave, thanks for this. yes i have never used the cancel midway script command, but oddly enough did know that you can never remember how to do it!

 

RKent - if you know how to do this, i'd appreciate it. might make a tidier script. otherwise, the script is basically as you show dave. so is the "L" for "last"? did not know that one. i tried using "previous", but as i'd just inserted it, that didn't work.

 

thanks all!

Link to comment
Share on other sites

Have you tried the command SSX? Once you invoke the command press enter once more for more options. It is all command line. It is what I use in script files for selection.

Link to comment
Share on other sites

i've updated my script and it work perfectly, so thanks all for the help.

 

and now i am interested....... how do you use this "ssx"? for instance, to select a block by name?

Link to comment
Share on other sites

i've updated my script and it work perfectly, so thanks all for the help.

 

and now i am interested....... how do you use this "ssx"? for instance, to select a block by name?

 

Enter SSX at the command line the press the enter key once more to see the options. You can then enter B to choose Block name from the options it gives you.

Link to comment
Share on other sites

ah sweet, thanks scribble. so i could alternatively add

ssx

block
[my block name here]

erase
previous

to my script and it will erase the block by selecting it. think i will have to look into that command, it looks pretty useful.

thanks again!

Link to comment
Share on other sites

Your very welcome. One other thing you might add to that would be the purge command. I use it if I'm replacing a block with an updated version that has the same block name or deleting the engineers stamp for the record drawings. That way engineers stamps are not in the electronic files shipped off to the client. Especially if there is electronic signatures.

Link to comment
Share on other sites

  • 11 years later...

If I wanted to add it to a routine I have already created how would this look? Below is what I have so far however, it doesn't seem to work as a .lsp.

 

(COMMAND "-SSX" "" "BLOCK" "BLOCK_NAME" "" "ERASE" "PREVIOUS" "")

Link to comment
Share on other sites

Try this

 

(defun c:eblk ( / bname ss)
(setq bname (cdr (assoc 2 (entget (car (entsel "\nPick a block for name "))))))
(setq ss (ssget "X" '((0 . "INSERT")(cons 2 bname))))
(command "erase" ss "")
(princ)
)

 

Link to comment
Share on other sites

1 hour ago, BIGAL said:

Try this

 

(defun c:eblk ( / bname ss)
(setq bname (cdr (assoc 2 (entget (car (entsel "\nPick a block for name "))))))
(setq ss (ssget "X" '((0 . "INSERT")(cons 2 bname))))
(command "erase" ss "")
(princ)
)

 

Thanks for the help so far.

 

It looks like this code picks requires user input to 'pick a block for name' I would like to put the block name in the code itself and run it with no user input.

 

any help would be appreciated.

Link to comment
Share on other sites

Remove the select bname line and add your block name "asdf" where bname exists in the ssget and all done, rename the defun to something more useful.

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