Merge segmented lines

Merge segmented lines

lrsmns
Enthusiast Enthusiast
413 Views
1 Reply
Message 1 of 2

Merge segmented lines

lrsmns
Enthusiast
Enthusiast

is it possible to merge segmented lines into one line?

lrsmns_0-1734687282812.png

i have these modellines that serve as room separator lines. However, they are segmented and would like to have it as a continuous line

 

0 Likes
414 Views
1 Reply
Reply (1)
Message 2 of 2

Moustafa_K
Advisor
Advisor

As an out-of-the-box API command, merging segmented lines isn't directly available. However, you can implement a solution by checking the relationship between the endpoints of the lines and their alignment.

 

Key Idea:

  • Verify if one or both endpoints of the second line lie on the first line.
  • If both points lie within the first line, you can omit the second line.
  • If one point lies outside, you can extend the first line to include the second.

See this pseudo code, not even tested, but just an example to make the idea close:

public static bool PointOnLine(XYZ p1, XYZ p2, XYZ tp, double tolerance = 0)
{
    var ab = Math.Round(p1.DistanceTo(p2), 4);
    var ap = Math.Round(p1.DistanceTo(tp), 4);
    var pb = Math.Round(p2.DistanceTo(tp), 4);

    if (Math.Abs(ab - Math.Round((ap + pb), 4)) <= tolerance)
        return true;

    return false;
}
Moustafa Khalil
Cropped-Sharp-Bim-500x125-Autodesk-1
0 Likes