Grasshopper

algorithmic modeling for Rhino

I'm fairly new to C#, and I'm trying to simply extrude a rectangle.

Now, I know that in Grasshopper I would just be able to plug a Rectangle3d in the Extrude component and set a vector, but in this case, I don't fully understand the syntax and how to put it all together.

This script has no purpose whatsoever, it's simply practice for myself.

private void RunScript(int start, int end, ref object A)
{

List<Point3d> pts = new List<Point3d>();
List<Rectangle3d> rect = new List<Rectangle3d>();
List<Plane> plane = new List<Plane>();
List<Extrusion> boxes = new List<Extrusion>();

Random random = new Random();
Vector3d vect = new Vector3d(0, 0, 1);


for (int i = start; i <= end; i = i + 2){
int random1 = random.Next(0, 100);
int random2 = random.Next(0, 50);
int random3 = random.Next(1, 5);
int random4 = random.Next(1, 10);

Point3d pt = new Point3d(random3, random1, random2);
Plane pl = new Plane(pt, vect);
Rectangle3d rt = new Rectangle3d(pl, random3, random4);

Extrusion box = new Extrusion(rt.Transform(Rhino.Geometry.Extrusion.Create(rt, random4, true)));

rect.Add(rt);
boxes.Add(box);

}

A = boxes;
B = rect;


}

Views: 2229

Replies to This Discussion

Get this and be a happy bunny

Attachments:

Not quite the happiest bunny atm, but will be when I understand your definition.

Thanks

Nice example Peter ;)

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service