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