Firstly I would like to say that the main principal of this question is not necessarily related to the revit API.
I am trying to create a "path of travel line" which has to go from the furthest point in a room following the shortest way along the wall, which means that there are 2 options the path can go(I added a picture for clarification)
I have an array of all the wall lines which are bordering this room, I have the index of the wall where the door is in and the index of the wall which has the furthest point in the room. However these indexes and the number of walls in the array vary from room to room.
How can I create 1 list that runs from doorIndex going up to furthestPointIndex and another list going from furthestPointIndex down to doorIndex considering that one of those 2 lists are going to just over from the end of a list(List.Count) to the beginning(List[0]) or the other way around.
From these 2 lists it would be easy for me to determine the shortest route
//this gets the walls in order in a list
List<Curve> edgeLoop = AbcRevitUtils.GeometryUtils.get_Curves(bottomFace);
Curve doorCurve;
Curve furthestCurve;
int index = edgeLoop.IndexOf(doorCurve);
int indexFar = edgeLoop.IndexOf(furthestCurve);
XYZ furthestPoint = new XYZ(0, 0, 0);
int startOrEnd;
//determine furthest endpoint on the furthest curve, a curve has 2 points in this case, a start point(0) and endpoint(1)
if (dPoint.DistanceTo(edgeLoop[indexFar].GetEndPoint(0)) < dPoint.DistanceTo(edgeLoop[indexFar].GetEndPoint(1)))
{
furthestPoint = edgeLoop[indexFar].GetEndPoint(1);
startOrEnd = 1;
}
else
{
furthestPoint = edgeLoop[indexFar].GetEndPoint(0);
startOrEnd = 0;
}
//this creates the line
Autodesk.Revit.DB.Analysis.PathOfTravel route = Autodesk.Revit.DB.Analysis.PathOfTravel.Create(doc.ActiveView, furthestPoint, dPoint);
//calculate which route in the loop is the shortest
//...
double path1 = 0;
List<double> path2 = new List<double>();
for (int i = index; i < indexFar; i++)
{
path1 += edgeLoop[i].Length;
}
if (index < indexFar)
{
for (int i = indexFar - 1; i > index - 1; i--)
{
int j = 0;
route.InsertWaypoint(edgeLoop[i].GetEndPoint(startOrEnd), j);
j++;
route.Update();
}
}
else
{
for (int i = indexFar + 1; i < index + 1; i++)
{
int j = 0;
route.InsertWaypoint(edgeLoop[i].GetEndPoint(startOrEnd), j);
j++;
route.Update();
}
}