I’ve already developed a few simple components from scratch, but I would like to have a few pointers for this new one. Basically I wish to create a tool that replaces this definition below. How would I reference these functions from the GH library. Thanks for your help
Array.Sort(); // or List<int>.Sort();
// Removing duplicate values from a list of ints is pretty easy using a double loop.
// But if you're worried about performance you can always try using a HashSet<int>
// Here's a loop approach:
List<int> zValues = ...;
for (int i = zValues.Count - 1; i > 0; i--)
for (int j = 0; j < i; j++)
if (zValues[j] == zValues[i])
Hi David, thanks for your help.
My question was more in the lines of if it is possible to access the built-in functions/components in GH in order to build new components such as the one in the example. I was looking around the GH SDK, but found no reference regarding this.
All the best.
Python has some functionality for this, but that was not backported to C#.
If you want to use gh components like that then you might as well just make a cluster. As you can see from David’s code, often the coded equivalent is more straight forward via loops VS the linear chains of GH components and my bet is that such things in the example you have will be much slower in performance written in the logic of Grasshopper connections as opposed to the logic of a C# loop.
Yes, I agree, Michael. I am trying to create a set of tools for a specific application. The tools are to be used by colleagues who are not versed in Grasshopper at all; by creating the components myself I can direct them towards a foolproof use of Grasshopper. Sometimes a cluster is a better approach, on occasions a new component is a superior option.
For instance, I’d like to have the sorting functionality work for any type of object according to a given criterium of choice.
points -> position
curves -> length
surfaces -> area
Should I use the GetType() method with a Switch-Case approach for this?