Grasshopper

algorithmic modeling for Rhino

hi,

I wanted to iterate the creation of some boxes which had to be moved and rotated with several datasets, finding it easier, I decided to script the whole stuff.

I started to make a script for making boxes (very easy I thought!) but I got stuck with IOnBoundingBox, members and so on.

finally, I took a shortcut but I didn´t want to leave the question unanswered. any help?

cheers

Views: 232

Replies to This Discussion

Hi Miguel,

the new SDK (called RhinoCommon) will have a much better Box class (which can be aligned, unlike BoundingBox which is always parallel to world axes). The next version of Grasshopper will support RhinoCommon so hopefully it will become easier then.

Note that IOnBoundingBox is a 'const' instance. You are not allowed to change it. If you want to have a box you can mess around with, you have to get an OnBoundingBox.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
OnBoundingBox is a little wierd in the sense that its not really geometry, just two points that represent the extreme corners of a box in world-oriented space. Ultimately, if you want to be rotating the box around, then you'll want to be creating actual geometry, which means creating a brep. The easiest way to create the brep is by using the OnUtil.ON_BrepBox method, which takes an array of On3dPoints. You can either create these points manually... or create a boundingbox via the two extreme corners, use the GetCorners method, then translate the On3dPointArray that's returned into an array of On3dpoint (which must be done manually :( )... Let me know if you need anything else.
David and Damien,

thanks for your replies, I am looking forward to trying that RhinoCommon.
I finally got to make it work with the Brep as you told me, Damien.
I´ll ask you if I have any more questions :-)

The code is really simple but I´ll post it in case it´s useful for somebody in the future:

On3dPoint[] array = new On3dPoint[8];
// in this case, I fill the array manually :-S
array[0] = new On3dPoint(0, 0, 0);
array[1] = new On3dPoint(1, 0, 0);
array[2] = new On3dPoint(1, 1, 0);
array[3] = new On3dPoint(0, 1, 0);
array[4] = new On3dPoint(0, 0, 1);
array[5] = new On3dPoint(1, 0, 1);
array[6] = new On3dPoint(1, 1, 1);
array[7] = new On3dPoint(0, 1, 1);

OnBrep box = new OnBrep();
box = OnUtil.ON_BrepBox(array);

A = box;


Thanks!
I hate working with Box topology. You always end up handling the 8 corners (or 6 faces, or 12 edges) manually. At least we're lucky Rhino is only a 3D modeler. If we had to deal with four-dimensional boxes we'd have to special case 16 corners, 32 edges and 24 faces...

--
David Rutten
david@mcneel.com
Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service