I’m overriding the ExpireDownStreamObjects() function of component. I want it to be DEPENDENT on the input value to the component. So essentially just:
If P = True, then have ExpireDownStreamObjects() behave one way (the default behaviour)
if P=False, then it should behave in a different way
protected override void ExpireDownStreamObjects()
{
if (P)
{
base.ExpireDownStreamObjects();
return;
}
}
The important part is how to read the value of P. P come from one of the sources to the component. Now if I just read P from the component itself I will get an old value. I want the new value that comes from the source.
So I’m instead reading the source
var sources = Params.Input[1].Sources;
if (sources?.Count > 0)
{
var source = sources[0];
source.CollectData();
var volatileData = source.VolatileData;
if (!volatileData.IsEmpty && volatileData.get_Branch(0)?.Count > 0)
{
var dataItem = volatileData.get_Branch(0)[0];
if (GH_Convert.ToBoolean(dataItem, out bool result, GH_Conversion.Both) && result)
{
base.ExpireDownStreamObjects();
}
}
}
However, it’s a hit or miss whether the source has been updated.
Is there a way to WAIT for the source param to be done before deciding whether I should expire downstream components or not?
Extra note: I’m trying to remove bug in the gatekeeper by Atte Mainio: Gatekeeper on github