weird behavior of SelectWindowPolygon

weird behavior of SelectWindowPolygon

wesbird
Collaborator Collaborator
821 Views
7 Replies
Message 1 of 8

weird behavior of SelectWindowPolygon

wesbird
Collaborator
Collaborator

Hi, I created a command to select TEXT/MTEXT within a closed pline. for one drawing, there are 300+ plines, all work fine except 10 of them. the 10 plines scatter everywhere in the drawing. for each pline, there is only 1 TEXT inside. The result of SelectWindowPolygon is much more than expected, the weirdest part is, it's the same as the result of all 10 plines. e.g. the result of top-left pline includes the one from the middle, the bottom-left, bottom-right, ...
I tested it in LISP, use ssget with the same list of points, and return the same incorrect answer, 10 TEXT from different pline. all 10 plines behave the same.
AUDIT + PURGE does not help.
I WBLOCK pline from pline layer and text from text layer out to a new DWG file, then it works.
has anybody experienced the same issue? is it possible to identify it in the code?

 

 

Windows 10 64 bit, AutoCAD (ACA, Map) 2023
0 Likes
Accepted solutions (1)
822 Views
7 Replies
Replies (7)
Message 2 of 8

norman.yuan
Mentor
Mentor

It is very likely what you ran into is the issue all AutoCAD programmers (whether doing LISP, VBA, .NET, C++) should know: when selecting entities with Window/Polygon/Fence... (in /NET API, you call Editor.SelectWindow[Polygon]()), the window/polygon/fence MUST BE WITHIN current view and the current view should not be zoomed out too far (if the view has too many entities crowded together and occupy huge area. Because these SelectXXXX() methods are designed for user to select on screen, thus the requirement of being within the current view and not zoomed to far out.

 

When using these SelectXXX() method, the common approach is to first zoom the current view to the extents of the window/polygon before calling it. In your case of 300+ polygons, you need to zoom to each of the polygon before use that polygon to select. Depending on the content of your drawing, repeated zooming might take time, and you might want to develop your own searching/selecting algorithms, if repeated zooming+SelectXXXX() calling takes to much time.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 8

a.kouchakzadeh
Advocate
Advocate

as Mr. @norman.yuan mentioned, the problem comes when you zoom in or out.

you can refer to this post as well

0 Likes
Message 4 of 8

wesbird
Collaborator
Collaborator

Thank you @norman.yuan and @a.kouchakzadeh

 

I do have code to ZOOM E before selection. 

one more thing I forgot to mention, I run my code in AcCoreConsole. I have problem to understand how the ZOOM E works under AcCoreConsole. is it a problem to run Editor.SelectXXXX() in AcCoreConsole?

I do test it in AutoCAD, both SelectWindowPolygon and ssget. 

next step I will test  zoom to each of the polygon and then select. 

but I still have a feeling, something wrong in that drawing. the same code works for other 1000+ dwg files. I wish I can post here but I cannot. 

 

 

Thanks again

Wes

 

AutoCAD 2021 and Visual Studio 2019 

Windows 10 64 bit, AutoCAD (ACA, Map) 2023
0 Likes
Message 5 of 8

norman.yuan
Mentor
Mentor

When you say "...the same code works for other 1000+ dwg files...", do you mean the SelectWindowPolygon() works with the 1000+ drawing when running in core console?

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 6 of 8

wesbird
Collaborator
Collaborator

Yes, that's correct. @norman.yuan 

it also works for 290 plines of the same drawing, only 10 plines got problem

Windows 10 64 bit, AutoCAD (ACA, Map) 2023
0 Likes
Message 7 of 8

norman.yuan
Mentor
Mentor

Then, you might want to simplify the drawing by erasing all the polylines except for the 10 in question, and test your code in AutoCAD and then in the core console to see what happens.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 8 of 8

wesbird
Collaborator
Collaborator
Accepted solution

Thank @norman.yuan

It turn out, all 10 TEXTs are part of a group. turn off the group selection then works. 

 

 

Thank you all again 

Wes

Windows 10 64 bit, AutoCAD (ACA, Map) 2023
0 Likes