algorithmic modeling for Rhino
Hello, I am a beginner of C# in grasshopper and I have a problem with writing code in custom additional code in grasshopper. Here is my code in C# grasshopper:
private void RunScript(int x, int y, ref object A, ref object B)
{
A = hehe(x, y);
B = hpt2(x, y);
}
// custom additional code
List<Point3d> hpt = new List<Point3d>();
public Point3d hehe(int a, int b){
Point3d hpp = new Point3d(a, b, 0);
return hpp;
}
public List<Point3d> hpt2(int a, int b){
for(int i = 0; i < a; i++){
for (int j = 0; j < b; j++){
hpt.Add(Point3d(10 * i, 5 * j, 0));
}
}
return hpt;
}
Basically, I just want to write the method in additional code so I can organize larger codes. But it keeps problematic saying that 'Rhino.Geometry.Point3d' is a 'type' but is used like a 'variable'. Is there any ideas about this?
Tags:
you need:
hpt.Add(new Point3d(10 * i, 5 * j, 0));
If you don't put the "new" expression in front of Point3d, it doesn't know that you are trying to construct a new point
Also just want to point out a potential error.
Whenever the component runs, your code will add new points to the already-existed hpt list, rather than to a brand new empty hpt list. So the list will keep getting larger and larger. Is this what you want to do?
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by