IF statement with different outcomes

I am feeding the nodes labelled 1 ,2 and 3 with the same information

1 is in designscript

2 is a custom node with the Python shown.

3 is a Python node with the same Python code as the custom node

I get 3 different outcomes.

1 just gives me the first half of the list. I think this has something to do with shortest lacing?

2 removes a level - why?

3 is the one I want. onput == output

Sorry for the messy snip.

Hi @Alien,

I guess the designscript is a lacing issue.
See this topic:
How does lacing work in Design Script? - DesignScript - Dynamo (dynamobim.com)

1 Like

@Alien ,

you can indexing in the contition too…

I tried that already and it doesn’t work.

My width and height are just integers.

It’s groups and lines that are lists.

Doing that actually splits the lines into a list structure like ‘groups’ which is not what I want.

I want the output to match EXACTLY the list structure of the input.

I’ve just answered the Python question though.
I had plugged in the wrong input for the custom node :person_facepalming:

The nodes don’t seem to have the same inputs. Or at least we can’t tell. Can you clean it up so we can see each of the inputs and all nodes use the same source of inputs?

DesignScript (just like nodes) will assume list levels. If you don’t specify those list levels or intended list structure for custom nodes, you can’t guarantee the same outputs. You’re supplying a single boolean as your conditional input but multiple sublists for your outputs. This is a mismatch in structure.

1 Like

Yep, see my message above!
Today is one of those days… :person_facepalming: :person_facepalming: :person_facepalming:

How do you put in the list levels in this instance for designscript?

I tried what @Draxl_Andreas suggested… I tried [0] after list and group but neither worked.

We’ve all been there. Even so, there is a difference between the methods you’re using. Structure is very important when dealing with condition statements.

How do I fix it in designscript?

I get the same output regardless of if it’s true of false.

lines and groups do have the same items but one is split into groups.

If you look closely they are not the same. The false condition returns all the same items (first item in false list) in the structure of the true result.

You just need to use the standard workaround to get the correct output.
DynamoSandbox_2022-11-16_10-00-45

1 Like

Thank you! Designscript really confuses me.

The tricky part is that DesignScript doesn’t always have a one-to-one translation for certain nodes. The If node and the index shorthand (list[index]) are the two most common culprits. This means there’s often a little more involvement when getting them to work “as expected”.