SelectFence unable to select entity if not shown on map extent.

SelectFence unable to select entity if not shown on map extent.

Anonymous
Not applicable
881 Views
4 Replies
Message 1 of 5

SelectFence unable to select entity if not shown on map extent.

Anonymous
Not applicable

hi,

I noticed that SelectFence unable to select entities if not shown on the map window.

I need to zoom out the extents to select an entity.

 

Is there a way to select entities without zooming out the map window. Please provide sample code.

 

Thank you.

 

Below is the code I am using.

 

TypedValue[] tvarr2 = new TypedValue[1];
tvarr2.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE,POLYLINE"), 0);

SelectionFilter sf2 = new SelectionFilter(tvarr2);
PromptSelectionResult psr2 = ed.SelectFence(pts3d, sf2);

if (psr2.Status != PromptStatus.OK)//no feature selected
continue;

0 Likes
Accepted solutions (1)
882 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor

This is well-known limitation of Editor.SelectFence/[Cross]Window/Polygon(): the fence line/window/polygon MUST be within visible view. SO, yes, you have to zoom out to make sure of this (but if the drawing extents are huge and you zoom out too much, the selecting result would not be as good as expected: those methods were meant originally for user to manaully do the selection in AutoCAD editor (so, you can imagine if you zoomed out too far, you would probably not be able to select by fence/window/polygon among so crowded entities, or the selection would not be as accurate as you wanted).

 

With your selection criteria (Polyline on layer "0"), simply looping through drawing database (modelspace, or any layout) to find these polylines would not be much slower than Editor.Selectxxxx(), except for, maybe a few lines of code more, but you do not have to bother zooming to ensure everything to be in view for selection. When I need to collect entities in code, I only use Editor.SelectAll() with filter, and avoid SelectFence/Winodw/Polygon whenever possible.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

Anonymous
Not applicable

hi norman,

thank you very much for your response.

I just want add to give you idea the tool I am creating.

I am creating a tool that check entities that intersects with other entities.

I used ed.SelectAll to get all entities (POLYLINE) and then loop to each objects and use ed.SelectFence to get features that intersect with the current object but I need to go the extent of each object to select features.

 

Before I tried AcadSelectionSet but the components seems missing in AutoCAD Map 2017.

 

 

 

 

 

 

 

 

 

0 Likes
Message 4 of 5

norman.yuan
Mentor
Mentor
Accepted solution

This issue itself have little to do with what you want to achieve. The selecting fence/window/polygon MUST be in the visible view. I am not sure why you mention AcadSelectionSet (a COM API object, which is not the topic of this forum, in general), but it gas been there since COM API available prior to year 2000 (AutoCAD Release 14.01), and of course it is available in AutoCAD Map 2017 (or any version of AUtoCAD Map, old or new). You did not explicitly mention, but if you somehow used, or want to use, COM API for selecting (use AcadSelectionSet.Select/SelectPolygon...) the same requirement (of selecting window/polygon be within visible view) also applies.

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 5

Anonymous
Not applicable

hi. norman

thank you so much for helping me out. that clarifies my query.

0 Likes