I have a component that instanciates a custom class, and then caches some geometry to display.
Mesh [] m_meshes = null;
Curve[] m_curves = null;
protected override void SolveInstance(IGH_DataAccess DA)
{
// delete cache ??
m_meshes = null;
m_curves = null;
object input = null;
if (! DA.GetData(0, ref input)) return;
var myClassInstance = new MyClass(input);
m_meshes = myClassInstance.GetPreviewMeshes();
m_curves = myClassInstance.GetPreviewCurves();
DA.SetData(0, myClassInstance);
}
When I disconnect input wires on my component, SolveInstance is not called, so the cache is not cleared and the previous preview is still displayed.
The way I solved this for now was to set all input params to optional, so that SolveInstance is always called. But then I have to manually “re-mandatorize” all inputs, i.e. checking for null and throwing an informative exception for each one. Presumably there is a better way to do this!