Hi,
I have been struggling with the issue for a long time. Hope someone can help me: How to control the order of segments in a reference polyline.
The shape might change sizes (I get the drawing from the client) and I need to build based on it. The thing is I use segments from the drawing and I wish to have it consistently in the same order.
I try to sort the segment by distance to a ref point, and it works well, till one drawing broke the order because of its dimensions… see GH file attached.
Any other ways to make it bullet proof?
Is there a way to make it happen?
Cheers.
The bottom line of what I am wishing for is that when I use item list on the segments Index 0 will always point to the same segment, no matter who draws the polyline, and no matter its dimensions. and the same Index 1 will always be the same element (let’s say the upper one would be 0, and the one next to it 1, and so on…). Hope it is clear …
Thanks.
What about setting Startpoint of curve (Curve Seam).
There is a seam component (input is parameter)
use a boundingbox to get a good reference point - depends a bit on the geometrical variations you expect …
I posted in the first place a code that shows the issue: an octagon that I got from a client, and I need to use a few segments of it to build a geometry, so let’s say, I need to choose the upper segment with the two small segments next to it. In each octagon I got the client drew it differently and the order is different.
So I am looking for a method to make each segment with same index, so when I take segment X- and I know it is the upper segment and I can manipulate it, and when I want to rotate the upper left segment, I know it is in index Y.
I guess it is not so complicated, I just couldn’t make it work…
so all your curves have this kind of topology ? a rectangle that is chamfered ? = 8 side Polyline ?
always aligned to World x-y / parallel to x-y-axis ?
I’m just thinking, assuming you’re working on the XY plane, is the segment on the most North coordinate (+Y direction) before manipulation, also the segment with the most north coordinate even after the manipulation?
because if you are able to define segment “number zero” and then go on counting clockwise or counterclockwise, then you get what you are looking for
but first you need to find a way to define your starting segment, that will work perfectly whatever your starting scenario is
first flips the curves (in sucha way they are always CCW), then numbers segments starting with 0 for the one that has center point with greatest Y value
so by scaling them things should always fall into a good solution
if you also rotate the curve to be manipulated, then this logic won’t work at all
if you use a reference point that is not dependent on the geometries (like for instance a fixed point on XY plane) there are cases in which the closest point to that reference one will also change
Seems like a good solution @Baptiste , thanks for that approach, didn’t know that sort along curve component… I will try to implement it in my code and see how it goes.
Cheers