Hi.
I have a polyline in my drawing and I have to repeat a lot of times the operation to create a line and find out the intersection point with the pokyline.
RIght now, I create the line and then I erase it . entity.Erase ( )
The issue is I want to avoid this step ( create the line and then erase it) because I said, maybe my command needs to do this operation thousands of times.
So, what could I do? maybe with "drawable" objects...although I have never used them.
Thanks in advance.
Solved! Go to Solution.
Solved by Virupaksha_aithal. Go to Solution.
Hi,
Try modify the line (set new start and end point of the line) instead of erase and recreating the new entity.
You don't have to add the Line object to the database to find the intersection... this will save lot of time and you won't need to erase it.
Just create the object in memory, even reusing the same symbol if you want, but don't add it to the transaction and to the database.
Edit: I see now you want to use the IntersectWith() function, that require an ObjectID... maybe you can work in 2D using the Line2d.IntersectWith() function. Here a C# function that will return an array of 2D points:
Later you can convert to 3D using the polyline Plane, if you need it.
public static Point2d[] PLineGetIntersection(Polyline p, Line2d vector) { if (p == null) return null; if (vector == null) return null; List<Point2d> vp = new List<Point2d>(); Point2d[] result = null; Tolerance t = new Tolerance(0.1, 0.1); for (int i = 0; i < p.NumberOfVertices; i++) { result = null; switch (p.GetSegmentType(i)) { case SegmentType.Line: LineSegment2d lp = p.GetLineSegment2dAt(i); result = lp.IntersectWith(vector, t); break; case SegmentType.Arc: CircularArc2d ap = p.GetArcSegment2dAt(i); result = ap.IntersectWith(vector, t); break; } // add partial results to final list if (result != null) vp.AddRange(result); } // convert list to Array as return value result = null; if (vp.Count > 0) result = vp.ToArray(); return result; }
I did such as @Virupaksha_aithal said, so now I create the line just once and finally I remove it.
However, I have noticed that actually this is not the issue about taking a lot of time. The issue is the "Surface.GetIntersectionPoint( ) method (C3D API) where I need to find the intersection of my sight to the surface and my surface has a huge amount of TIN triangles. In addition, I do this iteration every 2 meters.
My idea is increasing this first iteration , for example every 20 meters and then apply a sub-iteration (every 1 meter) once there is no solution (intersection has found).
Thanks for all.
Can't find what you're looking for? Ask the community or share your knowledge.