How to check which input parameter expired inside SolveInstance()

Hello everyone,

I am working on a custom component and I am wondering if there is a way to know which was the input parameter that expired and that cause the call to GH_Component.SolveInstance() method?
The reason is that depending on the expired parameter, I can avoid unnecessary computation.

KR,
Enrico

It’s too late in SolveInstance, as all expired parameters will already have recomputed and thus no longer be expired. You need to check this earlier, either by overriding ExpireSolution() or by handling the SolutionStart event of whatever document contains your component. The latter will probably give you the most accurate answer, but also requires you register and unregister from this event every time your component is added to/removed from a document.

I see. By overriding ExpireSolution() I can check if an input parameter expired through its Phase property? if is currently equal to GH_SolutionPhase.Blank it means that the input changed? Is this a good procedure to check it?

var phase1 = Params.Input[0].Phase;

Probably best to check if it’s not completed. Any other phase means you should consider it out-of-date.

1 Like