.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

does working SelectWindowPolygon just with 4 points ?

10 REPLIES 10
Reply
Message 1 of 11
bikelink
727 Views, 10 Replies

does working SelectWindowPolygon just with 4 points ?

inside this area i have a circle..


lpt.Add(new Point3d(5.0, 5.0, 0.0));
               lpt.Add(new Point3d(13.0, 15.0, 0.0));
               lpt.Add(new Point3d(12.0, 9.0, 0.0));
               lpt.Add(new Point3d(5.0, 12.0, 0.0));
               lpt.Add(new Point3d(5.0, 5.0, 0.0));


// if I add the red row  SelectWindowPolygon return Error. without this its return the objects.

               PromptSelectionOptions Opts = new PromptSelectionOptions();
               Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
               Point3dCollection Polygon = new Point3dCollection(lpt.ToArray());
               PromptSelectionResult res   = ed.SelectWindowPolygon(Polygon);

maybe I'm a stupid...but I guess that a polygon could be have more then 4 vertex..

 

10 REPLIES 10
Message 2 of 11
norman.yuan
in reply to: bikelink

SelectWindowPolygon()'s argument Point3dCollection can contains 3 or more Point3ds (To make a polygon, you need at least 3 points, right?).

Here "Window" does not mean a rectangle with 4 corners (while in SelectWindow(), "Window" means a rectangle, but only 2 points representing 2 opposite corners required). It means "window" selection, as opposed to "crossing" selection. That is only entities completely contained inside the polygon will be selected.

 

Message 3 of 11
bikelink
in reply to: bikelink

if I try to use with lisp (ssget "_wp".... (pointlist))

I can use 4 ,5 ,n points.  isn't it ?

of course i want to retrieve the object inside my polygon (6 vertex) fully included! (window)

Message 4 of 11
Jeffrey_H
in reply to: bikelink

Does that polygon cross itself or have to closed regions

You can also find your answers @ TheSwamp
Message 5 of 11
Jeffrey_H
in reply to: Jeffrey_H

Never mind that was answered here

http://www.theswamp.org/index.php?topic=35384.0

You can also find your answers @ TheSwamp
Message 6 of 11
bikelink
in reply to: Jeffrey_H

it's very simple... I have 4 points (not a simple square) (sometime 5 points) and I want to check all entities fully  inside.

The dbobjects could be any kind (solid3d, circles, ecc...)

 

Message 7 of 11
chiefbraincloud
in reply to: bikelink

Jeffrey_H (and Jeff_M at the swamp) are correct.  The points you provided will generate a boundary that crosses itself, which is not allowed.  (oops.  my eyes are playing tricks and I skipped right over the first point in your list, which made what I wrote before in these parenthesis invalid)

 

I don't know how you are coming up with the points you need to define your polygon, but in your example, if you swap the second and third points, it will work.

 

Coincidently, there is a recent thread on this discussion group about how to programmatically determine if a polyline intersects itself.   I just tried to find it, but I am having some trouble locating it at the moment

Dave O.                                                                  Sig-Logos32.png
Message 8 of 11
bikelink
in reply to: chiefbraincloud

ok , sorry but with this points i haven't intersections

that's a real situation.

 

              lpt.Add(new Point3d(2526.11913296339, 4761.82097707599, 0));
               lpt.Add(new Point3d(2250.71913296339, 4761.82097707599, 0));
               lpt.Add(new Point3d(2299.01913296339, 4713.52097707599, 0));
               lpt.Add(new Point3d(2526.11913296339, 4713.52097707599, 0));
               lpt.Add(new Point3d(2526.11913296339, 4761.82097707599, 0));

 

 

the shape (black color)  is regular, without intersections (i moved out from others lines in order to show it)

under this points we have some entities but the selection fails!

 

 

Message 9 of 11
bikelink
in reply to: bikelink

ok discovered....i must to make a little offset ..else  nothing is really fully inside !

 

 

Message 10 of 11
chiefbraincloud
in reply to: bikelink

After Looking at your image, I was going to suggest that circle might be touching the boundary.

 

And FYI,  I was going to say that there is no need to provide the final closing coordinate, as AutoCAD will automatically treat the polygon as closed.

Dave O.                                                                  Sig-Logos32.png
Message 11 of 11
norman.yuan
in reply to: bikelink

You may have already been aware of it, but just in case:

 

SelectWindow()/SelectWindowPolygon()/SelectCrossWindow()/SelectCrossWindowPolygon(), all of these methods have a critical limitation: the window/polygon MUST be in the visible area of he current view on the screen in order for this methods to work correctly. These methods are just mimic the manual selection picking.

 

When doing programmatic selecting with these methods, one may forget to make sure the points of the polygon is within visible area of the current view (eg. one or more points located off the screen). 

Also, if the drawing's extents are so big and the selecting polygon is so bag, the accuracy of selecting is just as good as the screen resolusion allows. AutoCAD really should have provided programmatical selecting methods that do not rely on visible view.

 

So, even your code let user to pick points before calling the SelecctWindowPolygon() method, the user may well zoom the view for picking last point that other picked points were off the screen far. SO, when the SelectWidowPolygon() is called, the assumed polygon is not within the visible part of the view, thus your code would fail.

 

Usually, before calling SelectWindowPolygon(), you want to zoom the view to make sure the polygon is within the screen.

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost