# Find parallel curves and cull by distance

Hi guys,

I could use some help with the following problem.

For a fabrication method (milling of glass) I need to check if curves are parallel and if the distance between them are larger than a certain distances (the used diameter of the drill bit). Curves may cross each other, but when 2 curves are too close to eahc other and parallel, this toolpaths overlaps resulting if messy and sharp edges . Hence I need to include a check on the generated designs if the curves are both parallel and too closes together

Since I couldn’t find a method with standard components or external plugins in any of the past topics, and as I probably need to iterate I tried my luck in python. I’m just starting out with python, so forgive my silly mistakes at this time

Any pointers in the right direction are much appreciated

current issues:

1. For now I ignore curved curves (couldn’t find a method in rhinoscript syntax) and just check for parallel straight lines by checking if the cross product of curve lengths is less than specified value. How to best include a check for all curves?
2. Type conversion failed from Number to Guid

Hello,

Maybe this can be a good start.
Group lines by angle with x axis, then for each couple of lines, test the minimum distance.
The result is a tree with each couple of close lines as a branch.
However there are cases where there could be more than 2 lines nearby, so there is a last test with `Point Groups` to group them together.

For the nonLinear Crvs of yours you can try something like this (an orientation check could be an option as well … plus planarity for the general case etc etc):

Other than that that’s a classic Hard Flat Clustering task where the condition could be (case: non Linear) as above or (case: Linear) a classic direction angle check (+ min dist).

Notify if you think that a C# that does that by the book could be useful. The standard core logic (shown a pt Clustering) is more or less the same (only the if content changes according the occasion):

Hi @PeterFotiadis , thanks so much, I’ll see if i can make this work. I did came across some previous code’s you kindly share here, that i can maybe tweak

Well … this is the complete if clause (no co-planarity check, assuming that … blah, blah).

Maybe later on (must find 10 minutes max for that) I’ll post a related HFC C#

It seems you’ve been right all along and C# is the path of the righteous man

In fact C# is the only path towards a proper Lambo (a classic lethal Balboni for instance) … but that’s another story.

The WIP C# is almost ready: finds 3 Clusters (one nonLinear and two Linears): is this what you want or there’s some other things to add? (Note: singles [Clusters with N ==1] are also included - but, if not required, that’s elementary to deal with).

Awesome. What you describe seems about right and i’ll give it a test with some other generated patterns. (Singles are not required, but no need to excluded it … who knows a future scenario it may come in hand)

PS: i quickly realized that as a designer me owning a Lamborghini will remain just a childhood dream. I always imagined how cool Miami Vice could be if Sonny Crockett would be driving a Countach LP5000 Quattrovalvole 1986, instead of that 1986 Ferrari Testarossa, but not let’s get offtopic

Not at all: you just need to cross the Rubicon (be on high demand, that is). That said that QV is a bit crap to drive (but stunning to look at). TS is like Las Vegas (kitsch to the max). What about some Eagle LowDrag E-Type?

Clusters_CrvsByDirectionAndDist_V1.gh (125.0 KB)

PS: Again: no planarity/co-planarity checks are included. Avoid inputing bananas.

PS: This HFC thingy is an entry level take on classic Clustering (O[N**2]). There’s various ways to boost vastly speed … but we are talking strictly internal (to the practice) stuff.

PS: Marry a rich girl > get an Aston DB4GT Zagato Sanction II

Code works like a charm and speed is <200ms for 400 crv’s so actually very useful in my code. Again, super grateful for the fact that you’re spending your valuable time assisting me and sharing the code ready to use

Yikes! that’s ultra pathetic. I’ll see if is possible to post some far more advanced take (for the search part) - but don’t cross your fingers (life sucks).

That said have in mind that this “core” logic can been used - as it is - for the general (of the general) case: define a Class with suitable Properties etc, sample your things in a List of that custom Type and then pass that List to the HFC Method (change - obviously - output Types accordingly).

Hey … the script includes boolean difference operation that takes minutes so your code is not the bottleneck

by some unrelated search and a freak coincidence I stumbled across a component “Clean overlapping curves” that comes close to what I was looking for. It’s from the Nautilus plugin. Maybe future users stumbling across this topic may find a solution in that one

@laurent_delrieu , maybe a suggestion for a future update, I think your component could benefit form outputting the index values, so to keep track of which curves are culled and which ones are split in 2 parts.