Suppose I have a number of components connected in sequence, say A→B→C or A→C & B→C and I have a global event handler that fires on change of model units in Rhino. These components’ output depends on the currently selected model units, so with every change I want them to update their outputs (solve).
If I have all 3 components registered to this event handler and call ExpireSolution(true) in the order they appear (first A, then B, then C), I will get into the following nasty situation:
- Component A solves, leading to B solving and C afterwards.
- Component B solves, leading to C solving as well.
- Component C solves.
Therefore, component B will be solved twice and C thrice. It happens that component C runs external tools which may take minutes to complete, therefore this situation is unacceptable for my plugin.
I have thought of some possible solutions but I am unaware of their feasibility in Grasshopper:
- Use
ScheduleSolution. However, this seems to shedule the solution of an entireGH_Documentand not specific components. - Expire the solution of A,B,C and at the end, run a solution for these components which will only run once.
- Use local variables to store the last solved units on each component and decide whether to continue in
SolveInstance. This could prevent component C running a second time if it already ran after step 1. above. However, at step 2. solution of component B will triggerSolveInstancefor component C, and even if I return early, the outputs will have been wiped out already.
This is a lot of information, so I could clarify if anyone thinks he can help.