Grasshopper

algorithmic modeling for Rhino

Hi guys,
I am trying to use RhUtil::RhinoGetTightBoundingBox Method (array<IRhinoObject^>^, OnBoundingBox^%) to get the bounding box of a set of geometries. However, I have no clue about turning them into IRhinoObject. Can anyone help me?
Cheers,
Daniel

Views: 455

Replies to This Discussion

Daniel,

what geometry do you have, where did they come from and which SDK are you using?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
They are coming from the Grasshopper components like breps and geometries. I am using .net sdk.
I want to zoom the viewport based on geometries. I am trying to use the way proposed in the following link:
http://wiki.mcneel.com/developer/sdksamples/zoomtoobject
Ok, I wouldn't bother with the RhUtil::RhinoGetTightBoundingBox method. You have a List of geometries, just call GetBoundingBox() on each one of those and Union the boundingboxes together.

My Rhino_DotNet is a bit rusty, but I just wrote code yesterday for doing this in RhinoCommon. Try the following:

Private Sub RunScript(ByVal geo As List(Of OnBrep), ByRef A As Object)
   Dim box As New OnBoundingBox()

   For Each brp As OnBrep In geo
     Dim p0 As New On3dpoint
     Dim p1 As New on3dpoint
     brp.GetBoundingBox(p0, p1)
     box.Set(p0, True)
     box.Set(p1, True)
   Next

   Dim view As MRhinoView = RMA.Rhino.RhUtil.RhinoApp().ActiveView
   view.ActiveViewport().DollyExtents(box, RMA.OpenNURBS.IOn.coordinate_system.world_cs)
   view.Redraw()
End Sub


--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David, you really solved my problem. One more question. What if the geometries inputed contain both mesh and brep? Which hint should I use for the input?
Yes, that is a problem. Perhaps it's time to switch to Grasshopper 0.7 and RhinoCommon? The code would look like this:

Private Sub RunScript(ByVal geo As List(Of GeometryBase), ByRef A As Object)
   Dim box As BoundingBox = BoundingBox.Empty
   For Each obj As GeometryBase In geo
     box.Union(obj.GetBoundingBox(True))
   Next
   doc.Views.ActiveView.ActiveViewport.ZoomBoundingBox(box)
End Sub


--
David Rutten
david@mcneel.com
Poprad, Slovakia
looks interesting. I would try that. Thanks again:)

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service