Any method to check if polyline is crossing an entity that belongs to a different layer?

Any method to check if polyline is crossing an entity that belongs to a different layer?

goswami12897
Enthusiast Enthusiast
1,517 Views
8 Replies
Message 1 of 9

Any method to check if polyline is crossing an entity that belongs to a different layer?

goswami12897
Enthusiast
Enthusiast

Hello,

I am looking for any method that can help me to identify that in 2d drawing at different points if our polyline is crossing the entities that belong to different layers and add a small markup at those points or a symbol to highlight it. Please suggest any methods that I can use using c#

0 Likes
Accepted solutions (1)
1,518 Views
8 Replies
Replies (8)
Message 2 of 9

kerry_w_brown
Mentor
Mentor

@goswami12897 ,

there is nothing in the API.

 

a crude idea would be to 

determine the bounding box of the polyline,

select all entities that are in or pass through that bounding box,

iterate the selection ,

    if the layer is the same, ignore,

    else test for intersections with the pline, and save the points,

        iterate the points list and add your marker of choice.

 

Regards,


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
Message 3 of 9

cuongtk2
Advocate
Advocate
Accepted solution

Make Point3dCollection (pcoll) from pline by pline.GetPoint3dAtt()

var objectids = ed.SelectFence(pcoll).Value.GetObjectIds();

Message 4 of 9

goswami12897
Enthusiast
Enthusiast

Thanks a lot it worked wonderfully for me after adding points at first and last vertex of polyline and then looking for objectids thanks a lot, is there anyway through which if entity is a hatch I can look for a point in that hatch too if it cuts the polyline?

 

0 Likes
Message 5 of 9

cuongtk2
Advocate
Advocate

from 0 to hatch.NumberOfLoops

BulgeVertexCollection bvc = hatch.GetLoopAt(0).Polyline;
// Make new closed pline from bvc => pline1

Point3dCollection pcl = new Point3dCollection();
pline.IntersectWith(pline1, Intersect.ExtendThis, pcl, IntPtr.Zero, IntPtr.Zero);
ed.WriteMessage(pcl.Count.ToString());
// pline1.Dipose()

Message 6 of 9

kerry_w_brown
Mentor
Mentor

@cuongtk2 

 


@cuongtk2 wrote:

Make Point3dCollection (pcoll) from pline by pline.GetPoint3dAtt()

var objectids = ed.SelectFence(pcoll).Value.GetObjectIds();


nice solution,

but there may be some edge case errors in the case of polyline arc segments.

 

Regards,

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 7 of 9

cuongtk2
Advocate
Advocate

Yes, that's entirely possible.

You can check GetBulgeAt(i) /= 0 and add Point with a factor of 1..n

GetPointAtParam(i+1/n)

Message 8 of 9

JamesMaeding
Advisor
Advisor

Note that solutions which iterate through each entity in source and target set will lead to long run times when lots of entities are present.

The solution to this is first generate bounding boxes for each item, then sort the target boxes by starting X coord and ending X coord. Then use that to figure the set of items between that for a given source item.

That allows you to cut out many items for the expensive actual intersect step, which you must do eventually.

That is paraphrasing, it takes time to set up such programs.

 

I do TIN surface programs, and you do a similar thing with tri bounding boxes, but you make a "tree" structure called a k-d tree. Then you can use that for certain things. This is all computational geometry and speeds things up to almost instant. Its fun but very detailed.

thx

 


internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties

Message 9 of 9

goswami12897
Enthusiast
Enthusiast

@cuongtk2 thanks most of the things worked out but I am not able to understand how to make a polyline from bulgevertexcollection? will you elaborate?

 

0 Likes