I created a custom class in Python to contain some geometry and other information. I implemented DrawViewportMeshes, DrawViewportWires and get_ClippingBox to be able to preview the geometry contained in instances of the class. I then created a number of GH nodes operating on these instances. The results are nicely visualized in Rhino, but only if the viewport also includes some Rhino geometry. When I pan the viewport and the Rhino geometry disappears from the viewport, everything suddenly disappears even though it is still within the viewport. As soon as the Rhino geometry comes back in view everything becomes visible again. Below is the code I’m using, anybbody have any idea what I’m doing wrong? It happens in both Rhino 6 and 7 (on mac).
class RhinoShape(gh.IGH_BakeAwareData, gh.IGH_PreviewData):
if self.bbox is not None:
try: box = None for geom in self.getGeometry(): try: tempBox = geom.GetBoundingBox(rg.Plane.WorldXY) except: if type(geom) != rg.Point3d and type(geom) != type(): tempBox = geom.get_Boundingbox() elif type(geom) == type(TextGoo): tempBox = geom.get_Boundingbox() else: tempBox = None if box == None: box = tempBox elif tempBox != None: box = rg.BoundingBox.Union(box,tempBox) self.bbox = box.GetCorners() except: try: self.bbox = rhinoscriptsyntax.BoundingBox(geometries) except: self.bbox = None return self.bbox def get_ClippingBox(self): if self.bbox is None: self.get_Boundingbox() return self.bbox def DrawViewportWires(self, args): #args of type GH_PreviewWireArgs pipeline = args.Pipeline for index, item in enumerate(self.getGeometry()): itype = type(item) colorValue = self.colors[index] if colorValue is None: colorValue = args.Color if itype is rg.Point: pipeline.DrawPoint(item.Location, Rhino.Display.PointStyle.X, 5, colorValue) elif itype is rg.LineCurve or itype is rg.Curve: pipeline.DrawCurve(item, colorValue, args.Thickness) elif itype is rg.Brep: pipeline.DrawBrepWires(item, colorValue) elif itype is rg.Circle: pipeline.DrawCircle(item, colorValue, args.Thickness) elif itype is Rhino.Display.Text3d: pipeline.Draw3dText(item, args.Color) else: print("Not addressed: " + str(itype)) def DrawViewportMeshes(self, args): #args of type GH_PreviewMeshArgs pipeline = args.Pipeline for index, item in enumerate(self.getGeometry()): if type(item) is rg.Brep: colorValue = self.colors[index] if colorValue is not None: material = Rhino.Display.DisplayMaterial(colorValue) else: material = args.Material pipeline.DrawBrepShaded(item, material) def BakeGeometry(self, doc, att, id): pass