Grasshopper

algorithmic modeling for Rhino

The below RHINO.SDK code allowed me to get a bounding box from the extents of a rhino model

 

Dim rmaIOnBoundingBoxModel As RMA.OpenNURBS.IOnBoundingBox = RMA.Rhino.RhUtil.RhinoApp.ActiveDoc.BoundingBox

Dim rmaArrayModelCornerPoints As New RMA.OpenNURBS.On3dPointArray

rmaIOnBoundingBoxModel.GetCorners(rmaArrayModelCornerPoints)

 

I cannot find a similar set of code to do the same in rhinocommon.

 

For instance;

 

Dim rmaIOnBoundingBoxModel As Rhino.Geometry.BoundingBox= Rhino.RhinoDoc.ActiveDoc.BoundingBox

 

does not exist. Any ideas?

 

 

thanks

 

Views: 1565

Replies to This Discussion

I'll add this function to the Objects list on the RhinoDoc. It will be available from the next version.
In the meantime, you'll have to iterate over the objects and grow your own box.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks david. Also the rhinocommon implementaiton of bounding box does not appear to allow you to use a user defined construction plane and origina as a referene for teh co-ordinat system of the points returned or assigned by the max min porperty. Points appear to have to be in world co-ordinates. Can you also allow for this flexibility?
Hi Duck,

GeometryBase (base class for almost all geometry types in RhinoCommon) has a GetBoundingBox() method that takes a Transform. You can use this to get aligned boundingboxes. Would you like another overload that takes a Plane instead?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
If possible I think it would be a good idea to get aligned bounding boxes. I havent delved too much in to Transform arguments. May be this will give the flexibility needed.
David

i have implemented the below code but it is totally inefficent. I have to loop through the object table everytime an input parameter to a component changes to get the extents of the model bounding box. For insatnce I have a model with 2600 objects, everytime i change or update the solution i have to loop through 2600 times. The updating of the display now is very laggy. Is there a better solution?

The only option right now is to set default extent values for teh bounding box. Previously in the Rhino dot net sdk it was possibel to get the extents by executing one statement.



Public Sub GetModelExtents(ByRef rcDocument As Rhino.RhinoDoc, ByRef rcMaxPoint3d As Rhino.Geometry.Point3d, ByRef rcMinPoint3d As Rhino.Geometry.Point3d)
'given a model, iterate through all bounding boxes to get maximim and minimum limits

Dim lMaxXordinate As New List(Of Double)
Dim lMaxYordinate As New List(Of Double)
Dim lMaxZordinate As New List(Of Double)


Dim rcRhinoObject As Rhino.DocObjects.RhinoObject
Dim rcObjectsTable As Rhino.DocObjects.Tables.ObjectTable = rcDocument.Objects

For i As Integer = 0 To rcObjectsTable.Count - 1
rcRhinoObject = rcObjectsTable.ElementAt(i)
If i = 0 Then
rcMaxPoint3d.X = rcRhinoObject.Geometry.GetBoundingBox(True).Max.X
rcMaxPoint3d.Y = rcRhinoObject.Geometry.GetBoundingBox(True).Max.Y
rcMaxPoint3d.Z = rcRhinoObject.Geometry.GetBoundingBox(True).Max.Z
rcMinPoint3d.X = rcRhinoObject.Geometry.GetBoundingBox(True).Min.X
rcMinPoint3d.Y = rcRhinoObject.Geometry.GetBoundingBox(True).Min.Y
rcMinPoint3d.Z = rcRhinoObject.Geometry.GetBoundingBox(True).Min.Z
Else
If rcRhinoObject.Geometry.GetBoundingBox(True).Max.X > rcMaxPoint3d.X Then rcMaxPoint3d.X = rcRhinoObject.Geometry.GetBoundingBox(True).Max.X
If rcRhinoObject.Geometry.GetBoundingBox(True).Max.Y > rcMaxPoint3d.Y Then rcMaxPoint3d.Y = rcRhinoObject.Geometry.GetBoundingBox(True).Max.Y
If rcRhinoObject.Geometry.GetBoundingBox(True).Max.Z > rcMaxPoint3d.Z Then rcMaxPoint3d.Z = rcRhinoObject.Geometry.GetBoundingBox(True).Max.Z
If rcRhinoObject.Geometry.GetBoundingBox(True).Min.X < rcMinPoint3d.X Then rcMinPoint3d.X = rcRhinoObject.Geometry.GetBoundingBox(True).Min.X
If rcRhinoObject.Geometry.GetBoundingBox(True).Min.Y < rcMinPoint3d.Y Then rcMinPoint3d.Y = rcRhinoObject.Geometry.GetBoundingBox(True).Min.Y
If rcRhinoObject.Geometry.GetBoundingBox(True).Min.Z < rcMinPoint3d.Z Then rcMinPoint3d.Z = rcRhinoObject.Geometry.GetBoundingBox(True).Min.Z
End If
Next

End Sub
Hi Duck,

sorry about the long silence, we got stuck up in the mountains due to bad weather for an extra day. I'll try to get around to this tomorrow.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hey, no its fine.

Im making good progress on bounding boxes and boxes using rhino common. I follow now how you can set up non world aligned boxes based on a local plane and origin and use them to test if objects are contained within them. I can get by right now just assuming an initial default value for the model extents. Hope the weather gets better!!

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