[Pufferfish] Question on the curve average components

I am working on a simple script that reduces the number of curves generated by a flocking algorithm.
The idea is to create a grid, then target the curves that are contained within the same cell by setting the rule that if each curve’s start point belongs to the cell, then the curve is in.

Afterwhat, I make an average curve of the group of curves contained in the same cell by using the Pufferfish components created by @Michael_Pryor

All my input polylines are made of the same number of segments (8) and the same number of Control points (9) and knots (9). You can see it in the following image :

However, the output from the pufferfish Average component generates polylines that have different number of segments (varying between 6 and 8) and different number of control points/knots (up to 33).

The following image shows in the right my original curve, and on the left the pufferfish curve.

I must have the hole output curves made with the same number of segments.

1)- Does anyone know how to parameter the curve Average Component for such an operation ?
I have checked the plugin’s example files, but I didn’t get the behavior of the component.
2)- Is the average component the right way to go for such operation ?

Thanks a lot !

You got some example file of your curves?

Yes ! Here is the file… Thanks for your help @Michael_Pryor .2020_05_31_Average.gh (97.6 KB)

AveragePolyline.gh (38.1 KB)


Yeap in this case is do what @Mahdiyar did. The Pf one is quite complex under the hood to deal with lots of curve types / mismatches and looks more at the shape of things than the structure. I can add this condition override in a future update.


Thanks a lot @Mahdiyar and @Michael_Pryor! indeed making the average of the vertices is nice way to deal with it ! Looking forward for a Pufferfish update !

I just looked at the file and didn’t realize you are averaging pairs. In that case just use Tween Through Curves which by nature has good polyline conditions built in because it is easier to measure from A to B in a predicable way.

Had a minute and made a quick update and re-uploaded as Pufferfish V2.9, go re download it. Now Average Curve and Weighted Average Curve have this method added. There are two conditions of the input curves to meet that method.

  1. They must all be polylines (per branch)
  2. They must all have the same control point count (per branch)

2020_05_31_Average_New.gh (99.9 KB)

and of course works with more than two polylines

but in general if it is just curve pairs, Tween is the better route to go for simplicity.

1 Like

Hi @Michael_Pryor ! Yes I received a notification that you reuploaded the example file the grasshopper group ! Thanks a lot for adding this !