Connect points with lines to Center and minmize length

Hi RadovanG,

do you know if anythin changed between V5 and V6 and C#?
Since I have V6 the script has problems. Maybe, do you have a a solution of it?

grafik

all the best,
Befuec

Hi

It is something weird with C# component in V6/GH - you can not declare methods with generic type parameter!!! So, solution is to use type int instead of generic type T and component will work OK. Here is code that you have to change/replace in C# component:

    public List<List<int>> Permutations(List<int> inputCollection)
    {
        List<List<int>> result = new List<List<int>>();
        if (inputCollection.Count == 1)
        {
            result.Add(inputCollection);
            return result;
        }
        for (int i = 0; i < inputCollection.Count; i++)
        {
            List<int> newInputCollection = new List<int>(inputCollection);
            newInputCollection.RemoveAt(i);
            var permutationsNew = Permutations(newInputCollection);
            for (int j = 0; j < permutationsNew.Count; j++)
            {
                List<int> permutation = new List<int>();
                permutation.Add(inputCollection[i]);
                permutation.AddRange(permutationsNew[j]);
                result.Add(permutation);
            }
        }
        return result;
    }

Again - thank you! sounds easy and now, it sounds clear.

One last point is open: If I want to change the lenght of lines e.g. from 3 points to 5 points per line, I want to integrate a new variable. But I don’t know how to integrate it properly. the new variable only show up as an object but not as a variable.

Thanks for the effort, helps me a lot for my work :slight_smile:

You’ll have to right-click on the input parameter and set the appropriate type hint ( looks like int in this case)

This sounds very arbitrary and strange - @DavidRutten is it a bug in GH1.0?

1 Like

You can declare them, but the autocomplete gets confused and messes things up. You have to specifically press Escape to cancel autocompletion when declaring things like List<int>. It’s a major drag but it doesn’t seem as though the people we bought the editor control from are interested in fixing things any more.

1 Like

Hi all,

I worked with that script you all helped me with a lot and would like to ask about some change in the counting - I want to do an optimization but my c# knowledge is unfortunately not yet big enough to solve the problem.

For example
If I have 21 points to connect.
In the current script the points are sorted like this: 5, 5, 5, 5, 1 (see picture, line with 1 point marked in orange)

I want the script to sort the points like this: 5, 4, 4, 4, 4.

So somehow I want to introduce a list with <5,9,13,17,21> to the script but don’t know how to integrate and count in each loop.

Can anybody help me?

connPH_Rev1.gh (9.5 KB)

Here is the code connPH_Rev2.gh (11.5 KB)

Some changes were necessary due to the fact that permutations will take long time when points-per-line gets more then 8.In such case other algorithm is used. Values in pattern less then 1 are ignored.

1 Like

as always, brilliant Radovan. Thanks a lot! :):grinning: