@dale, the reason I want to inherit is, that I usually use boundingboxes properties and then process them.
So I thought I might adapt this to my needs quite easily.
import Rhino
# Fancy bounding box class
class MyBoundingBox(object):
def __init__(self):
self.m_bbox = Rhino.Geometry.BoundingBox()
# Set this bounding box from a Rhino bounding box
def Set(self, bbox):
self.m_bbox = bbox
# Set this bounding box from a GetObject
def SetFromGetObject(self, go):
if go:
for objref in go.Objects():
rc, bbox = Rhino.DocObjects.RhinoObject.GetTightBoundingBox([objref.Object()])
if rc:
self.m_bbox.Union(bbox)
# Set this bounding box from a list of geometry
def SetFromGeomtryList(self, list):
for geo in list:
bbox = geo.GetBoundingBox(True)
self.m_bbox.Union(bbox)
# Unions a Rhino bounding box to this bounding box
def Union(self, bbox):
self.m_bbox.Union(bbox)
# Returns this bounding box as a Rhino bounding box
def Get(self):
return self.m_bbox
# Get the minimum corner point
@property
def Min(self):
return self.m_bbox.Min
# Get the maximum corner point
@property
def Max(self):
return self.m_bbox.Max
# Test
def test():
go = Rhino.Input.Custom.GetObject()
go.SetCommandPrompt('Select curves')
go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
go.GetMultiple(1, 0)
if go.CommandResult() == Rhino.Commands.Result.Success:
bbox = MyBoundingBox()
bbox.SetFromGetObject(go)
print(bbox.Min)
print(bbox.Max)
if __name__=="__main__":
test()