algorithmic modeling for Rhino
Hy Guys, I'm working on a script which should get the Bounding Box of all Grasshopper Previews.
Is this possible without baking ?? And is it possible to get all control points of the previewed breps, lines, points, curves, ... ??
I haven't seen something like this in the forum so I have opened a new discussion.
Thanks for all your help.
Nice Greets
Alex
Tags:
There's no method for this. The GH_Document does retain a BoundingBox which it uses as clipping box during redraws, but this is a private field that has not been exposed as a public property.
What you need to do is iterate over all IGH_DocumentObjects in the document, see which objects implement the IGH_PreviewObject interface, cast them and aggregate all the ClippingBoxes. In VB:
Dim clipBox As BoundingBox = Rhino.Geometry.BoundingBox.Empty
For Each obj As IGH_DocumentObject in doc.Objects
Dim prvObject As IGH_PreviewObject = TryCast(obj, IGH_PreviewObject)
If (prvObject Is Nothing) Then Continue For
If (Not prvObject.IsPreviewCapable) Then Continue For
If (prvObject.Hidden) Then Continue For
clipBox.Union(prvObject.ClippingBox)
Next
Note that this will usually give you fast boundingboxes, not accurate ones. As for control-points, that's a lot harder. Why do you care about the control-point clipping box for all Grasshopper geometry?
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks David.
I want to place a Camera and always "look" at the last placed object from my definition. And therefore I was thinking, that always looking at one of the control points of the last object.
But it will be much easier to look at the BoundingBox.Center, or ?
Rhino zooming works with boundingboxes so you could presumably use the boundingbox to set both target and zoom factors. The problem will be how to detect what the last object was and when exactly to focus on its preview geometry. I can't see a solution that will consistently work.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by