Grasshopper

algorithmic modeling for Rhino

Hi All,

I have a series of Breps referenced from Rhino. I want to calculate the bounding box of these Breps from different planes (worldXY, rotated worldXY etc). The calculations seem to be working correctly (ie I get the correct bounding box dimension) but when these calculated bounding boxes gets output from the custom GH component, they all get displayed oriented in the WorldXY plane.

 

Is anyone having the same problem or does anyone have any suggestions?

 

 

------------------------------------

Dim CurrentBrep As Brep = Nothing            

Floor.CastTo(CurrentBrep)

 

Dim worldXY as plane(origin,unitx,unity)

WorldXY.Rotate(someangle,unitz)


'get bounding box.

Dim CurrentBox As BoundingBox = CurrentBrep.GetBoundingBox(WorldXY)

BoundingBoxList.Add(CurrentBox)

 

DA.SetDataList(1, BoundingBoxList)

Views: 8338

Attachments:

Replies to This Discussion

I think that's how it's supposed to work now. You can reference a box object that will be correctly oriented in world coordinates like this:

 

Private Sub RunScript(ByVal b As Brep, ByVal pl As Plane, ByRef A As Object)  

   Dim bx As box  

   Dim bbox As boundingbox = b.GetBoundingBox(pl, bx) 

   a = bx  

End Sub

 

Hi Kermin,

 

a BoundingBox object is defined by two corner points (lower-left-front and upper-right-back) and is therefore unable to store orientations. If you want an oriented boundingbox you'll need to use the overload of GetBoundingBox() that takes a Box object.

 

Dim box As Box = Box.Unset

CurrentBrep.GetBoundingBox(Plane.WorldXY, box)

 

I added the Box type specifically because I ran into problems like this more often. Traditionally boxes are represented in Rhino core as arrays of 8 corner-points, but there's no guarantee of orthogonality there.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Sounds great. Now I understand what's happening.

 

Thanks.

Hi David,

I'm trying to get some oriented bounding boxes similar to this example but it gives me an ArgumentTypeException error: expected StrongBox[Box], got Box

import Rhino as rc

plane = rc.Geometry.Plane.WorldXY

plane.Rotate(math.radians(-120), rc.Geometry.Vector3d.ZAxis)

box = rc.Geometry.Box.Unset

bbox = geometry.GetBoundingBox(plane, box)

Any idea what's going wrong here? What is a StrongBox in general?

Thanks,

Mostapha

StrongBox seems to be a python thing. No habla Python.

--

David Rutten

david@mcneel.com

Tirol, Austria

Thanks David! I wrote my own version for now.

Hello

import Rhino as rc
import math

plane = rc.Geometry.Plane.WorldXY
plane.Rotate(math.radians(-120), rc.Geometry.Vector3d.ZAxis)
a= x.GetBoundingBox(plane)

 x as geometrybase (item)

the resulting boundingbox is a self in this method.

Best,

M.

Hi Mostapha,

this seems to work:

import Rhino as rc
import math

plane = rc.Geometry.Plane.WorldXY
plane.Rotate(math.radians(-120), rc.Geometry.Vector3d.ZAxis)
bbox = geometry.GetBoundingBox(plane)
box = rc.Geometry.Box(bbox)
xform = rc.Geometry.Transform.Rotation(math.radians(-120),
        rc.Geometry.Vector3d.ZAxis, rc.Geometry.Point3d.Origin)
box.Transform(xform)
a = box

Cheers

emilio

Huh ... hadn't seen Marios's reply before posting ...

emilio

Hi Mario and Emilio,

Thank you for your help. I'll definitely use your suggestions next time.

Cheers,

Mostapha

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