Find the collection of entities intersecting with a given block

Find the collection of entities intersecting with a given block

Anonymous
Not applicable
2,768 Views
6 Replies
Message 1 of 7

Find the collection of entities intersecting with a given block

Anonymous
Not applicable

Hi,

I want to get a collection of objects intersecting with a given block/DBObject/entity. How can I do that ?

The IntersectWith method returns collection of intersection points. If I have to use this method, how can I get the intersecting entities with the given points' collection?

Thanks in advance.

0 Likes
Accepted solutions (1)
2,769 Views
6 Replies
Replies (6)
Message 2 of 7

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> The IntersectWith method returns collection of intersection points

Yes, it returns the intersection points between 2 entities.

So if you want to check 10 objects against one line, you have to call the method 10 times. And when you get intersection points returned for 3 entities you know that these 3 objects are intersecting.

 

- alfred -

PS: I guess your thread would be better placed in the forum for AutoCAD customization with .NET >>>there<<<

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 7

Anonymous
Not applicable

Thanks for replying.

The thing is that I have a drawing file which contains entities intersecting each other. I want to collect the entities intersecting a block and I don't know how many entities are intersecting the block, so, don't know how mnay times I should call the intersecting method. Is there any direct or indirect way to get the intersecting entitites' collection ?

0 Likes
Message 4 of 7

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

>> Is there any direct or indirect way to get the intersecting

>> entitites' collection ?

Sorry no, AutoCAD does not have a build in function which returns intersecting objects to one base object.

 

In case you are sure that you have the base entity on screen (inside the display area) then you can

  • zoom to extents of this entity, so the complete base object is visible
  • next create a selection with crossing window based on the lower-left and upper-right corner of the display
  • now you have a reduced number of entities for which you can now check in a loop each of the entities with the IntersectWith method.

Take care, if your tool should run independent from screen content (or with just database without editor) then a selection with crossing window does not return a valid result.

 

- alfred -

 

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... I want to collect the entities intersecting a block and I don't know how many ..., so, don't know how mnay times I should call the intersecting method. Is there any direct or indirect way to get the intersecting entitites' collection ?


It would not be difficult to find entities that cross the bounding box of a Block.  But that doesn't mean they necessarily intersect with the Block's contents.  Here, if the red and yellow parts are a Block, the dotted blue rectangle is its bounding box.  It would be easy to find the green Line and the white Arc with a crossing window using the bounding box, but would you want the Arc, since it doesn't intersect any of the Block's parts?

Kent1Cooper_0-1614603248746.png

And there's a problem [in a very quickie trial] -- I find I can't use the IntersectWith method on two objects if one of them is part a Block and the other is not.  I used (nentsel) to pick an object in the Block, and converted that and an outside object into VLA objects.  I got nil return from IntersectWith, in out-in-the-drawing use and also within both BEDIT and REFEDIT on the Block.  Maybe there's another way to go about it that I haven't thought of.

Kent Cooper, AIA
Message 6 of 7

Anonymous
Not applicable

Hi,

Thanks for the reply. I tried but didn't get you completely since I am a newbie to AutoCAD .Net api and don't know about VLA objects, how to use REFEDIT and BEDIT command etc. 

Anyway, thanks for paying attention to my query.

0 Likes
Message 7 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... I am a newbie to AutoCAD .Net api ....


There's a whole >Forum< devoted to that, where you may get better help.

Kent Cooper, AIA