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

Alternative to SelectCrossingPolygon​ outside the current viewing area.

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
952 Views, 4 Replies

Alternative to SelectCrossingPolygon​ outside the current viewing area.

I have floor plan drawings, where rooms are divided by polygons.  Inside these rooms are block references, line, arcs, ... witch is the content of those rooms.  I am trying to associate all objects with their "surrounding" polyline.

 

Now for business reasons, the SelectCrossingPolygon​ method is perfect, but it does not support selecting objects outside of the current viewing area.  But I cannot afford to have my user's screen stop moving by itself, zomming on the rooms to select what's inside it.  And moreover, I don't realy need to select these items, but I just need to identify them.

 

Is there some similar mechanism that would allow me to obtain all objects crossing or within a certain set of points (forming a polygon)?  Mabee a DatabaseService method?

 

In the past, I have developped a pretty good PointInPolygon algorithm, but that is eighter based on the bounding box of the objects of its center point (center of the bounding box), witch can lead to errors (imagine a convex L shaped desk fitted around a column).  This is to some extent acceptable most of the time but creates irregularities in the associations, and does not consider odly-shaped block definitions, where the selection methods do....

 

Any ideas are welcom!

Thanks in advance!

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

I do this kind of stuff all the time. You need to address the following challenges to get this to work

 

  1. Identify the Polyline that represents the room. This is a non-trivial problem. You can look for ploylines on a particular layer, but in inexperience,drafters are not so good at ensuring drawing objects are on correct layers. This is the easiest, but most error prone method. It may be your only option for existing drawings. You can also roll your own input routine, but this is not as easy as you thing if you allow curves in the pline. Either way, once you ID your pline:
  2. Roll through the database looking for your block references, testing them to see if they are continued within your pline. To test, get the centroid of the blockref (you may need to look into the block def and find the item(s) to use for your odd shaped items), create a ray with the base point being the location. Use the intersect method to test he number of times the ray intersects with the pline. If the count is odd, the point lies inside the pline.
  3. Create a link between the objects.

This is not a huge challenge, but you will be writing a lot of code. Also, you have to handle a TON of gray areas, like what constitutes "In" the room; if the point is on the line; where is the insert point of the blockref, etc.

 

Good luck

 

HomeBoy Out

Message 3 of 5
Anonymous
in reply to: Anonymous

Thanks for the response!

 

Unfortunatly, that will not solve my problem.  This would give me (pretty mutch) exactly the same results has the PointInPolygon (mathematical - winding number algorithm) approach.  The only thing it would add would be to probably consider correctly any arcs in the polyline.  With VBA (our current production version of the app is in VBA), the IntersectsWith methods was too slow compared to the mathematical solution even considering this advantage....

What it will not give me is the consideration of the actual visual dimentions of the block; it only considers its centroid.  Again, if we have a long L shaped desk that folows the boundary of a room, the desk might not be positioned in the same room as its centroid.

Unless there is a garentee that the centroid of an object WILL ALWAISE be on a "graphical" part of that object...  And that is a possibility, I am far from being a geometry expert, but I taugh it was not in fact garenteed to be on a visible part of that object....

 

Thanks alot for the input!  Happy to know that I'm not the only one doing this kind of thing in this world!  😉

Message 4 of 5
michael.robertson
in reply to: Anonymous

I've been fighting this problem of having to have the objects in the current view for the Selection routines to work for years now, and the slowness of the IntersectWith method is not the main problem, if you are using large coordinate systems (like a State Geographical) then it will return incorrect intersection results.

Mike Robertson
FL. Dept. of Transportation
CADD Applications Developer
Message 5 of 5
Anonymous
in reply to: Anonymous

You can "simulate" the Crossing polyline by creating an area object (I did it with a hatch in VBA) which will give you everything that intersects (Inside or crossing). Problem is that intersectwith uses the bounding box for block refs, so you will get some false hits. For those items, you can roll through the points that make up the geometry in the block def, and see if they are inside your pline.

 

HomeBoy Out

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