Please find below the steps I used to retrieve a set of connected lines / arcs / etc. from a sketch (to be used as a sweep path later).
1. find the start point in the sketch (by selecting it or assuming it's the first of all sketch points);
2. get the lines / arcs / etc. connected to it;
3. pick the one you didn't already process (otherwise it could go back and forth between two connected lines);
4. store the line / arc with the other already processed ones (collection);
5. get it's length and add it to the total length found so far;
6. get the other end point of the line / arc / etc.
7. use that point as the first point and continue from step 1 for each connected line / arc / etc.
The above is more a brute-force than an elegant / simple solution, but it's the only approach I could think of.