"If" node doesn't output an array of values

Hi all,

I’m sorry if this seems like a very basic question (tried to look for some similar posts but couldn’t find one).

I am trying to use the “If” node to generate different results. In my example, the goal is to delete either CAD Link or Imported Links.

When the user ticks “CAD Imports”, I want the script to delete all imported CAD files generated from Bimorph’s CAD.ReportInstances node.

Problem is, the final “If” node does not get all list values from the previous node - it only takes the first item on the list. I thought I could remedy this with Lacing but If node doesn’t have Lacing property. I tried the Longest Lacing node but not sure what combinator input needs.

Please refer to the snapshot of the script below:
image

Thank you all!

Jahzeel

Hi all,

Interestingly, adding a “List Create” node to only one of the previous results gives me the list. However, adding them to both gives me only the first item.

Here, I get all items from the list:
image

After adding “List.Create” node to both, I get the same issue again:
image

The problem probably has to do with how if node works on different length lists for the true and false values. The common alternative is ScopeIf but it can be a bit trickier.

I don’t remember the exact details but I am sure there are several posts somewhere comparing the two. Some older examples include IF node and If and Lists of different lengths

2 Likes

Hi @kennyb6,

Thank you so much!
I tried ScopeIf and also found that Clockwork also has ScopeIf+ node.

I tried to use both and found that Clockwork’s node does the job better, and is also faster.

The normal ScopeIf somehow loads slower, and gives a “null” output to my CAD.ReportInstances node (didn’t know a proceeding node could affect the nodes that precede it). I tried to test it several times… I guess it’s not stable enough?

Anyway, thank you so much for introducing me to this node :slight_smile:

2 Likes

You could try the old style if in a code block:

choice = {list1,list2};
choice[x ? 0 : 1];

which will never disappoint :wink:

5 Likes

Hey,

I agree with you in using Clockwork ScopeIf+, which I believe contains a version of Jean-Marc’s solution.

As you’re finding you need to be careful with the OOTB ScopeIf, it is designed to be used within custom nodes…

I had graphs freeze because the unexecuted branch was being used for other nodes downstream (say you wanted a dated folder inside an undated folder, but not having the first one dated you can accidentally freeze the second create node and the whole thing stops).

Hope that’s of interest,

Mark

1 Like

Thanks @Jean-Marc.
I am still a little unfamiliar with some code block notations.
But thanks for suggesting this as I can study & look it up. :slight_smile: