Polar Array using C#?

I’m not shearing if Grasshopper section is the correct place to put a C# question. But I’m trying to optimise my Grasshopper graph migrating slowly to C#. This is my first script and is working using text. The API I was able to find was in VB. Where I can find info about API PolarArray and how to implement it? Is it posible an example?

The C# script with multiple surface brep will run faster than Grasshopper?

Brep myBrep = null;
if (!DA.GetData(0, ref myBrep)) return;
Brep myNewBrep = myBrep;
// Code here…PolarArray
DA.SetData(0, myNewBrep);

MyProject1_FirtTest.gha (6 KB)

Hi @AlanMattano,

The ArrayPolar command uses a rotation transformtion, or Transform.Rotation, to transform objects from one location to another.

– Dale

If you are just rewriting a single gh component (polar array in this case) chances are it won’t be faster (unless you are doing something special like multi-threading), most likely it will be the same or slower since the gh components are written in c# already. What you can make faster is larger processes, for instance maybe you have a process that takes 10 components, you can write that process as one component, in that case you can make things faster usually depending on how well your coding is.

1 Like

Thx Michael 4 answering!

This is argument for a new tread but If I make a “cluster” of 10 components looks like is not the same as fast as writing that 10 into C#. Is there a way in Grasshopper to make a build, bake or a compiler that takes that group of components or cluster and create a .gha or .dll automatically? Usually graph tools like this one has this final compiler option. Is a Cluster as fast as C#? Do I has to code in C# manually? Is it missing in the workflow a final compiler with data oriented optimized machine code?

A cluster will not be faster, often it is slightly slower than even the gh definition. As far as I know there is no way to automatically make a cluster into a script, mainly because the logic of the script would be different due to having the ability to loop etc.

1 Like

Still I do not get it. Is my first time scripting using Rhino API and I did not understand how to use the Transform class from Geometry with Brep.
myBrep.Rotation(…is not possible
Do myBrep has a Transform?
There is a
myBrep.Rotate
After creating angleRadians, rotationAxis and rotationCenter can you give me an example how to use
Transform.Rotation together with Brep?

You need to create the Transformation to use.

You can create the transformation first, then use it like this:

Transform rotate = Transform.Rotation(yourAngle, yourVector, yourPoint);
yourBrep.Transform(rotate);

or you can create the transformation in the transformations execution like this:

yourBrep.Transform(Transform.Rotation(yourAngle, yourVector, yourPoint));

2 Likes