Grasshopper

algorithmic modeling for Rhino

Hi everybody,

Could anybody comment how to get the corners of a box. I tried:

Point3d[] corners = new Point3d[8];

for(int j = 0; boxes.GetCorners().Length;j++)
{
   corners[j] = boxes.GetCorners(j);
}


And it is definitely not the right one

Cheers

Views: 1436

Replies to This Discussion

Point3d[] corners = box.GetCorners();


Though from your naming I assume you actually have a collection of boxes? If that's the case, do you want all corners of all boxes inside a single array?

--
David Rutten
david@mcneel.com
Seattle, WA
Hi, David. Yes, in fact, I´d like to have each set of corners in different arrays.

Thanks!
Ok, then you need to have a data structure that actually supports multiple lists of point arrays. Something like this:

List<Point3d[]> corners = new List<Point3d[]>();
foreach (Box box in boxes)
{
    corners.Add(box.GetCorners());
}


--
David Rutten
david@mcneel.com
Seattle, WA
Thank you!
:-)
Hi Miguel,
you could also do it a bit more similarly to the way you started. (So, this is an alternative with an array of arrays, or jagged array):

Point3d[][] corners = new Point3d[boxes.Count][];

for (int i = 0; i < boxes.Count; i++)
   corners[i] = boxes[i].GetCorners();

Ah, change "boxes.Count" to "boxes.Length" if boxes is an array.

- Giulio
______________
giulio@mcneel.com
McNeel Europe, Barcelona
Hi Giulio,

Thanks!

Giulio,

could you post a vb version of this example. I can't find any examples of jagged arrays for the vb component on the site and the one (months and days of months) on the vb.net site give me a syntax error.

-Jeff

Hi Jeff,

this is the equivalent code from C# to Vb.Net

Dim corners As Point3d()() = New Point3d(boxes.Count - 1)(){}

For i As Integer = 0 To boxes.Count - 1
corners(i) = boxes(i).GetCorners()
Next

- Giulio
_______________
giulio@mcneel.com
McNeel Europe

Thanks Giulio
box.GetCorners() returns all 8 corners.

Dim pts(8) As point3d
pts = box0.GetCorners()

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service