I think GH_ParamAccess, besides Item, List and Tree, needs Onlyitem and Onlylist.
e.g. Wrap Input of List Item component should not be entered into a multiple item list. Of course, make menu items is a good solution, but it can’t be automated.
It need Onlyitem.
e.g. Path Input of Tree Branch component should not be entered into a multiple branch tree. and, make menu item doesn’t solve the problem.
It need Onlylist.
Of course, this essence is a compatibility issue, can also be solved with field.
I want Onlyitem to send a warning and just use the first item when the input data is a multiple items list. Onlylist is similar to this.
Sounds like you can perform those checks inside the component SolveInstance
or BeforeSolveInstance
methods just by looking at the input datatree.
private bool _validInputs;
protected override void BeforeSolveInstance()
{
_validInputs = true;
if (Params.Input[1].VolatileData.PathCount > 1)
{
AddRuntimeMessage(
GH_RuntimeMessageLevel.Error,
"The second input may not contain more than a single list of items.");
_validInputs = false;
}
}
protected override void SolveInstance(IGH_DataAccess access)
{
if (!_validInputs && access.Iteration > 0)
{
// Perhaps the Iteration check doesn't work for you,
// in which case the access.ParameterTargetIndex(int) or
// access.ParameterTargetPath(int) may.
access.DisableGapLogic();
return;
}
...
}