Disable conduit automatically


I am working on a plug-in for Grasshopper that has a component that creates and interacts with a Rhino display conduit to display a textured mesh. It works great… almost too great… I can’t figure out how to shut it off automatically when the component is deleted or grasshopper is closed. I tried putting myConduit.Enabled=false in the visualization component’s destructor, but that code is not being executed when the component is deleted from Grasshopper.

How do I go about disabling or deleting the conduit when the owning grasshopper component disappears?


You probably need to override the component’s RemovedFromDocument method, and disable the conduit in that method.

Alternatively, don’t use a DisplayConduit but override the components DrawViewportWires and/or DrawViewportMeshes methods.

1 Like

Thank you!

RemovedFromDocument() does the trick.

I’ll have experiment with DrawViewportMeshes as well to see if it gives me any additional functionality. e.g. disabling the mesh drawing when the component’s Preview is turned off.


DrawViewportMeshes is a conduit with some extra knowledge to know when to draw things based on details like preview being enabled.

Thank you!

DrawViewportMeshes works perfectly! I just took my old conduit code and put it into DrawViewportMeshes using the IGH_PreviewArgs parameter in place of the conduit’s DrawEventArgs parameter. Disabling on delete is automatic as well.