Sorting segments of polycurves in sync with a matching set

Trying to clear a hurdle on a larger problem I’m looking to work out.

The general workflow right now is taking a set of breps from a rhino file that have been laid down on the xy plane, offsetting their top and bottom faces and generating a line that corresponds to the distance between each segment of the top and bottom offset faces.

One issue I had to get around is the incidence on two of my sample solids of ‘chamfer nicks’ in their corners (Branches 5 & 11). I managed to create some logic to cull the extra curves that result on the top faces from the tree. The issue is that there is a desync of the order of the edges, though only on two breps that I wouldn’t expect it to occur on (Branches 0 & 3). This causes an error where certain intersections are not registering.

I’m looking for a method for resorting the line segments in some manner to put the two loops of curves back in sync. (See screenshot, 6 expected points are missing)

There’s additional work that should occur after the point this definition ends, but for now I’m trying to wrangle the trees before I hit that point.

Any insight is appreciated, thanks in advance!
edge angle testing.gh (102.1 KB)

It’s been a few days and no bites. I dug a bit further into the forum and found a few promising conversations. I had high hopes for Inputing lines in GH, and sorting them in order and tried an implementation of that script into my file, unfortunately the results are still out of synch.


I’m wondering if Adam Mounsey or some other more code oriented individual can diagnose either why python’s sort is/isn’t working or if there’s a simple solution to this issue.

Thanks all

I don’t think there is a “simple” solution to this issue, especially in cases where the edges are angled. Just reviewing your elaborate code is a chore.

Starting completely from scratch, I get the following - all dimensions are duplicated, I didn’t try to avoid that. And I’m sure your criteria are more complicated…


edge angle testing_2023Feb2a.gh (104.5 KB)

1 Like

I definitely agree with that. I re-wrote the code up to the point where the curves are split into segments.

I used a simple C# script to orient the outline curves consistently. It just reverses curves that have clockwise orientation.

if (crv.ClosedCurveOrientation() == CurveOrientation.Clockwise) crv.Reverse();
ccw_crv = crv;

The line segments were not in sync. between your 2 exploded curves because the closed curves they come from have different seam loctions. I used the Align Curve Seams from the PufferFish Plug-in to correct this.

I left the rest of your code following this point untouched. This is the output from feeding the code I changed into your remaining code:

edge angle testing_re1.gh (103.1 KB)

-Kevin

Joseph and Kevin, I want to thank both of you for taking the time to dig through my spaghetti, I know it’s not fun to have to parse other people’s code especially when you’re not sure what they’re trying to accomplish.

That being said, Kevin, I’ll need to take some more time to double confirm, but it looks to me like you fully solved my issue while also showing me an excellent new technique for finding those top and bottom faces. I thought the list index pulling 0 and -1 was a great move.

I’ll admit that since ultimately I’m hoping to use this code for an internal project at work, I was probably making my life harder by trying to avoid too many plugins, but the service that pufferfish is providing in this code is too good to pass up.

Thanks again all, I really do appreciate your help with this one!