I need to create a BBox on any Objects, i use boundingbox and AddBox, that’s work on 3D Objects ( curves/Surfaces/polysurfaces) , but if my object is planar (2D) i can’t , the Rhino.BoundingBox() return 8 ¨points, but AddBox fail , i think because 4 points are at the same exact place.
In Rhino boundingBox command, we can choose 2D cuves as output , but i don’t find same possibility in rhinoscript.
Is there a way to use Addbox ( or something similar) on planar objects ?
Thx !
Call Main()
Sub Main()
Dim strObject, arrBox, sfrBox
Hi @Cyver
You can check for duplicate points in your arrBox and see if there are 4 unique points - that will be the case for planar 2D objects. See the sample code below:
Dim idObject : idObject = Rhino.GetObject()
Dim arrBbox : arrBbox = Rhino.BoundingBox(idObject)
Dim arrCulled : arrCulled = Rhino.CullDuplicatePoints(arrBbox)
'checking if 4 unique points were left after culling duplicates
If Ubound(arrCulled) = 3 Then
'getting planar-object-plane aligned bounding box for correct sorting of not-in-Cplane planar objects
'otherwise the polyline points may not be connected in the right order
Dim arrPlane : arrPlane = Rhino.PlaneFitFromPoints(arrCulled)
arrBbox = Rhino.BoundingBox(idObject, arrPlane)
arrCulled = Rhino.CullDuplicatePoints(arrBbox)
Dim idBoundingRectangle
idBoundingRectangle = Rhino.AddPolyline(Rhino.JoinArrays(arrCulled, array(arrCulled(0))))
End If