want to delete something from a BLOCK without entering it

want to delete something from a BLOCK without entering it

shoshi9753
Observer Observer
1,339 Views
16 Replies
Message 1 of 17

want to delete something from a BLOCK without entering it

shoshi9753
Observer
Observer

Steps to reproduce
I have a block and I want to delete something from it without entering it
Every time I want to move or delete something from the block, I have to enter the block and do the action

 

Expected results
If I want to delete something from a block
I want there to be a command so that I don't have to go into the block and delete
But delete from the outside...
So that I don't have to go out and in every time
Is there such a command?

 

Actual results
delete outside the block, it is not comfortable

 

URL where issue occurs
delete

 

Browser
Other

 

OS
Other

 

 

 

 

[ The subject line of this post has been edited for clarity by @pendean Original: block ]

 

0 Likes
1,340 Views
16 Replies
Replies (16)
Message 2 of 17

pendean
Community Legend
Community Legend

Nothing built-in does that if you find REFEDIT and BLOCKEDIT command to not be options.

 

Are you perhaps wanting something like XCOPY command but erases instead? Or something else?

0 Likes
Message 3 of 17

Kent1Cooper
Consultant
Consultant

That can't be done without entering the Block definition, but if you mean you want a command or routine to handle that part for you....  The attached BlockElementDelete.lsp with its BEDEL command seems to do that [lightly tested].

Kent Cooper, AIA
Message 4 of 17

calderg1000
Mentor
Mentor

Regards @shoshi9753 

Try this code, to eliminate block entities, with minimal testing

;;;___
(defun c:erb (/ da s sn)
  (setq	da (vla-get-activedocument (vlax-get-acad-object))
	s  (car (nentselp "\nSelect entity inside Block: "))
	sn (vlax-ename->vla-object s)
  )
  (vla-delete sn)
  (vla-Regen da acAllViewports)
)

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 5 of 17

john.uhden
Mentor
Mentor

@calderg1000 ,

This reminds me of a long standing issue.

nentsel and nentselp actually return a list of the deepest nested entity through the shallowest, like a line within a block "A" which is contained in block "B" which is contained in block "C."

The first item in the list (car (nentselp)) is the deepest, but suppose we want to select block "B?"

(nth 2 (nentselp)) will return the 3rd entity name within the list, but we would have to dump or entget the entity to find out what it is.

What we should do is put the  list of the family tree in a DCL list_box with recognizable entity types and names (if applicable) and layer to allow the user to select the desired family member (not necessarily great grandpa Linus but maybe father North Arrow).

I had an old routine like this, but I would have to do a lot of excavation to find it.

John F. Uhden

0 Likes
Message 6 of 17

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

.... nentsel and nentselp actually return a list of the deepest nested entity through the shallowest, like a line within a block "A" which is contained in block "B" which is contained in block "C."

The first item in the list (car (nentselp)) is the deepest, ....


Mine in Message 3 goes for the deepest with all those "Next" entries in its REFEDIT command, assuming not more than three levels down, but more "Next" entries could be added if it might be further down than that.

 

It doesn't use (nentsel) because you can't directly delete the entity returned by that if it's nested.  So it does it with REFEDIT, digs down to the lowest [it is hoped] nesting level, and gets rid of the object there, re-using the pick point from the original selection, but not using the entity name from it.

 

But yes, if the thing you want to remove from a Block is, for example, an entire nested Block, not just a deepest-level piece within that, then some method would be needed to determine which nesting level you're after.  If that's the need, I suspect it's just as easy to give in and "enter" the Block definition in REFEDIT or BEDIT to do what is wanted.

Kent Cooper, AIA
0 Likes
Message 7 of 17

john.uhden
Mentor
Mentor

@Kent1Cooper ,

Thanks for that information.  I wasn't aware that you can't delete an entity name from somewhere in the middle of a family tree.  Not even (vla-delete)?

John F. Uhden

0 Likes
Message 8 of 17

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

.....  I wasn't aware that you can't delete an entity name from somewhere in the middle of a family tree.  Not even (vla-delete)?


By golly, it turns out that (vla-delete) will do it, though it's necessary to REGEN to see the change.  [I had made my claim based on trying (entdel) as well as ordinary ERASE with the nested-entity name.]  That lets the command shorten a little, to the attached version [minimally tested].

Kent Cooper, AIA
0 Likes
Message 9 of 17

john.uhden
Mentor
Mentor

@Kent1Cooper ,

That's nice to see.

Now how about providing the choice to vla-delete a different member of the family tree?

Actually what I haven't created (yet) is a way to copy a nested entity (not the deepest) from an xref into the current drawing.

John F. Uhden

0 Likes
Message 10 of 17

shoshi9753
Observer
Observer

Yes, great!!
This lisp really helps, that's what I meant,
It's not perfect but it's good enough
The only problem is, why do I have to re-upload every drawing I open??

0 Likes
Message 11 of 17

Kent1Cooper
Consultant
Consultant

@shoshi9753 wrote:

.... why do I have to re-upload every drawing I open??


That's true for any routine that is not part of AutoCAD itself -- it needs to be loaded before you can use it.  My preferred way to have that happen in all drawings:

 

Go to >this< in Help and learn about acaddoc.lsp.  To find out whether you already have such a file, put this in at the command line:

(findfile "acaddoc.lsp")

and if you have one, it will tell you where it is.

Put the .lsp file in a location where AutoCAD knows to look [OPTIONS command, Files tab, Support File Search Path list], and in a plain-text editor such as Notepad, put this line in acaddoc.lsp [whether the only thing in it, or if you already have the file, added to what's already in it]:

(load "BlockElementDelete")

and it will be loaded in every drawing you create or open.

 

If you prefer, you can have it always ready to be loaded, but not actually loaded into a given drawing until you call for the command.  Instead of the line above, use:

(autoload "BlockElementDelete" '("BEDEL"))

Kent Cooper, AIA
Message 12 of 17

Kent1Cooper
Consultant
Consultant

@shoshi9753 wrote:

..., It's not perfect but it's good enough ....


What should be different to make it perfect?

Kent Cooper, AIA
0 Likes
Message 13 of 17

john.uhden
Mentor
Mentor

@Kent1Cooper ,

It's a good thing you didn't make it "BED."  Using it would make me sleepy.

John F. Uhden

0 Likes
Message 14 of 17

john.uhden
Mentor
Mentor

@Kent1Cooper ,

Yes, I am being picky, but it's better to ask than accuse...

Why wasn't ent made local?

Nevermind.  I see that it was just a case of mistaken identity.

John F. Uhden

0 Likes
Message 15 of 17

shoshi9753
Observer
Observer

it's not perfect,
Because it deletes only one object per command and it is not possible to select a selection of several objects at the same time and delete

0 Likes
Message 16 of 17

Kent1Cooper
Consultant
Consultant

@shoshi9753 wrote:

it's not perfect,  Because it deletes only one object per command and it is not possible to select a selection of several objects at the same time and delete


Everything about Message 1 was in the singular, so that's what my routine did.  It's easy enough to make it let you pick more than one [see the attached revised version], but be aware that you must pick on each object individually -- there is no way that I know of to select nested objects with a window or fence or lasso.

Kent Cooper, AIA
0 Likes
Message 17 of 17

john.uhden
Mentor
Mentor

@Kent1Cooper ,

Ahem, you didn't mention "acadprefix" or "trustedpaths."

Or does autoload take care of that?

John F. Uhden

0 Likes