Leaving input data list empty without stopping component to run?

hi guys,
I am wondering how to leave an input empty while not stopping the component to run.

Here is what I have: The input is supposed to be a List of integers:
pManager.AddIntegerParameter(“obstacles”, “obstacles”, “obstacles”, GH_ParamAccess.list, new List() { });
(I dont know about the “new List() { }”, was just something I tried)

Appart from that I have added in my
“protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)”
method the following:
pManager[15].Optional = true;
which is my obstacle input above.

Further more I have been adding this in my SolveInstance:
obstacles = new List();
if (!DA.GetDataList(15, obstacles))
{
return;
}

Now, everything is fine if I plug an input with no data:

But I want this to work without me providing data at all:
image

Basically, if the obstacles List of integers stays empty, there are just no obstacles…
Any idea how to do this? Might just be an issue of not knowing the syntax…

Thank you!

even though ur setting the input as optional, which you should be doing, the “return” statement here is forcing SolveInstance to terminate if no data is retrieved from that input.

What you should do is simply call
DA.GetDataList(15, obstacles));

or if you need a conditional for some other reason then, do not call “return”

1 Like

I implemented this and got rid of the if statement with the return;, but till does not work.

Seems I had to place my component again on the canvas and re-plug wires. Cheers!

Great. Deleting the component and then undoing also works, saves u from having to replug 20 or so params as you seem to have here.

1 Like

Oh wow, thats a great trick to know, thank you!