C# how to refer rhinoscriptsyntax


(Andrewsthekkathsachin) #1

i used python in grasshopper to make components referring to > help > rhinoscriptsyntax

now i am trying learn and decode C# script in grasshopper … but i cant find a way to refer these C# syntax to understand them

(David Rutten) #2

Only Python uses the RhinoScriptSyntax, which was developed to ease transition from RhinoScript to Python.

In C# you’ll have to switch to standard RhinoCommon classes and methods.

(Andrewsthekkathsachin) #3

can you please help me out how to use rhinocommon… itz bit confusing

(Andrewsthekkathsachin) #4

for example
referring to this C# script
i cant find " CreateTri " in RhinoCommon

    //Create an empty list of lines to hold our snowflake curves
    List<Line> lines = new List<Line>();
    //Call the CreateTri function and pass the radius and flip parameters
    Polyline tri = **_CreateTri_**(radius, flip);
    //Create an array of Lines by extracting the segements from the triangle
    Line[] triangle = tri.GetSegments();
    //Add these three lines to the lines List
    //Create a temporary list of lines
    List<Line> tempList = new List<Line>();
    //Begin the while loop
    int i = 0;
    while(i < num){
      //make sure the list is empty by calling the Clear() method
    A = lines;

(David Rutten) #5

And what’s the CreateTri function like?

(Andrewsthekkathsachin) #6

i guess itz for making triangles

(David Rutten) #7

Not what for, what’s it like? I.e. how does it work? I don’t think it’s a McNeel function, unless someone has seriously changed naming conventions we tend to use.

(Andrewsthekkathsachin) #8

CreateTri(radius, flip)

(Andrewsthekkathsachin) #9

i have no idea sir

(David Rutten) #10
Polyline triangle = CreateTri();
List<Line> lines = new List<Line>(triangle.GetSegments());

for (int i = 0; i < num; i++)
  List<Line> temporary = new List<Line>(lines);
A = lines;

This would be the C# way of doing it, but the CreateTri() and CreateKochSnowflake() methods are not available in Rhino. I don’t know where you go them from but I imagine they are provided by some sort of python import.

(Andrewsthekkathsachin) #11

gh-csharp-adv02.cs (3.2 KB)

i got this from a tutorial


(David Rutten) #12

Dude it’s already in C#…

(Andrewsthekkathsachin) #13

you mean CreateTri() is in C# by default ?

(David Rutten) #14

That webpage shows the source of the CreateTri and KochSnowflake methods in C#.

(Andrewsthekkathsachin) #15

thanx man !!:kissing_heart::kissing_heart: