1

In ModelSpace I have an area limited by some curves (joined them to have AcDbRegion).

I have also drawn AcDbLine.

What I need is to split line to get lines only inside area.

I know how to get intersection points, but how can I find if line conecting two intersection points is inside? or outside area?

CAD Developer
  • 1,532
  • 2
  • 21
  • 27

3 Answers3

5

Have you tried BREP API? Try something line this:

Autodesk.AutoCAD.BoundaryRepresentation.Brep brepEnt = new Brep(myRegion);
PointContainment pointCont;
brepEnt.GetPointContainment(thePoint, out pointCont);
if (pointCont == PointContainment.Inside)
{

}
Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44
  • Looks interesting, but there is one more problem. My applications runs on ZWCAD. As I know (maybe I'm wrong) , ZRX not contains BREP. – CAD Developer Mar 17 '16 at 14:41
3

If you want to do it manually (with an algorithm that will work with any APIs), I would suggest you use the "winding number algorithm" for the purpose of Point In Polygon calculation. It does not take in consideration bulges in the polygon, but it is very fast is implemented properly allowing me to beat AutoCAD's API by a fold of 2x.

Another possibility, is to draw a temporary line from the point you are testing to infinity, and test how many intersection it has with your polyline. If the number of intersections is odd, then you are inside the polyline; if it is even, then you are outside of the polyline. If the intersection testing is done with the API of the application, it should take in consideration the bluges in the polyline vertices.

JFTxJ
  • 542
  • 6
  • 17
  • But ultimately, Augusto Goncalves' answer is the correct one for AutoCAD's API..... – JFTxJ Nov 15 '16 at 13:34
  • Good idea. For sure I need to consider bulge segments. I have region and line. They intersect in lets say 4 points. so I need to check which couples of points are inside or outside area (region) . line between couple of points always intersect region in both endpoints. But I can use StartPoint and take direction to EndPoint, with large distance. if such line intersect region even times, line is inside. and that is what I need. THANK YOU – CAD Developer Nov 15 '16 at 14:19
0
  1. Get the polyline that defines the outside of your region.

  2. Select by polygon using the region polyline vertices. Or select by crossing polygon using the polyline vertices if you want everything inside or crossing the region.

Miiir
  • 731
  • 1
  • 9
  • 12
  • OK I have line and intersection points, so I can split line to many curves, then I can select by vertices, but: 1. acedSSGet works only on visible area. but I'm not sure I draw by ARX in visible area, I can zoom, but it makes application "blinking" and user will not like it I suppose 2. I can select by vertices, but what about bulges? crossing by polygon let me select with arc segments? – CAD Developer Mar 17 '16 at 14:52