Hello guys,
I am creating a component and at the same slot I want to be able to plug a list of different objects, but the checks fail. Precisely:
if (DA.GetDataList(0, List<XXXXX> provided_as_obj)) {
var obj = provided_as_obj[0];
if (obj is Object1)
// do something
else if (obj is Object2)
// do sth else
}
Object1 and Object2 are custom made classes.
- Do I need to implement something in order to be able to use the
obj is Object1
check? My checks always fail. - How should I declare provided_as_obj and what should I put in place of XXXXX? I used
List<object>
but as I said the checks later fail.
What confuses me is that when Object1
is string
and Object2
is int
, for example, the checks work.
I got some inspiration from here: multiple type input/output from custom components - Grasshopper and c# - Type Checking: typeof, GetType, or is? - Stack Overflow
Thanks!