Remove Null result without running C# Script

Hi everybody.
I was having a bit of a problem writing a C# on Grasshopper script. All the Scripts I write without running the Script result in null. So how to remove that. Thank you!
C# Script.gh (6.1 KB)

P.S. Note that an unmodified (empty) C# component has the same <null> output:

missing

I reload file no have assembilies
C# Script.gh (6.7 KB)
file

Instead of trying to modify the default behavior of C# components, why don’t you just deal with a <null> result downstream?

Because I have a lot of scripts like this, if I use it, I have to use it many times over and over again Clean Tree component. I don’t think that’s good

Why would you use scripts with no input? I give up.

Input is the value true or false

I don’t know C# but here is a way to do it in Python:

if ToF is None:
    a = []
else:
    a = ToF

null_data_2023Jan28b
null_data_2023Jan28b.gh (3.3 KB)

1 Like

private void RunScript(object x, object y, ref object A, ref object B, ref object C)
{
  B = new DataTree<object>();
  C = new List<object>();
}

But you must also detect that the ‘ToF’ input is null.

1 Like

2023-01-28-09-59-02

private void RunScript(bool TOF, ref object A)
{
  if (Component.Params.Input[0].VolatileDataCount == 0)
  {
    A = new DataTree<object>();
    return;
  }
  A = "TOF is " + TOF.ToString();
}

VolatileDataCount.gh (4.6 KB)

Not bad but what if ‘ToF’ is not the first component input?

2023-01-28-10-12-57

private void RunScript(bool TOF, ref object A)
{
  var i = Component.Params.IndexOfInputParam("TOF");
  if (Component.Params.Input[i].VolatileDataCount == 0)
  {
    A = new DataTree<object>();
    return;
  }
  A = "TOF is " + TOF.ToString();
}

VolatileDataCount.gh (6.2 KB)

2 Likes

thanks you so much!