Create different paths for the workflow if one list is empty

Hi guys,
So, I’m working on a routine. It is almost finished. But I have one last problem. In case the list in “List.AllIndicesOf” is = Empty the node “List.RemoveItem” should be ignored. So then it does not give an error message, leading to a false feeling that something is wrong in the routine.

Does anyone have ideas on how to deal with the problem? I’ve tried some things with If, others with Rhythm Helpers. But I couldn’t get it to work.

If the “List.AllIndicesOf” is empty


(“List.Remove” do not remove a thing and shouldn’t give an error message)

If The List.AllIndicesOf is not empty: “List.Remove” should remove the index that appears in List.AllIndicesOf

Document:
MATCH PLAQUINHAS_10.dyn (217.3 KB)

Check the ScopeIf or ScopeIf+ node.

Hi @Marcel_Rijsmus Thanks for your quick response, but apparently that can’t solve my problem. because I need that if the test is = true the remove node is simply ignored. In this case bellow, I gave an “” for the remove item node, and it gave me an error.

There’s not really a good way to handle these situations. The best option is usually to use Python, which I think is what the ScopeIf+ node does. What does the error for that node say?

1 Like

i think the Dynamo team is working on a better version of the if node.
any progress there @solamour ??

2 Likes

There are many options here, and personally think the best of which is to wrap all of the content in a single custom node. One thing to point out, there is no error here, but a warning. And error indicates that something has gone wrong, but this is a warning meaning ‘check the results,’ which in any case should be the first thing anyone does after running any kind of optimization routine.

1 Like

Sol’s off for a bit longer, so I’ll weigh in here. I realize I am not an adequate substitute, but I want him to enjoy the well deserved time off while ensuring things are getting answered. So to that end:

There is a desire to review this node to revamp how it works, but nothing which is exposed at this time nor is there a timeframe for any kind of release. To be informed quickly, keep an eye on the Dynamo Builds which are released and the version releases as that is where any new functionality along this line or others will be announced.

4 Likes

Aloha team! Apologies - was offline for a bit of time :slight_smile:

We have scoped the new IF Node and will be starting work on this in the not-to-distant future, but as it stands right now we have not begun the actual development work.

In the meantime, there are easy workarounds that can be used in DesignScript to achieve results similar to what will be built.

2 Likes

Good morning Guys, Thanks for the replies and sorry for the delay, It was already night here.
So @Nick_Boyts The warning that the node gives me is
“Warning: List.RemoveItemAtIndex operation failed.
Value cannot be null.
Parameter name: source”
@Marcel_Rijsmus Thank you for contacting dynamo team

@solamour @jacob.small I understand, thanks for the information … But I didn’t understand how I could deal with this problem in a short time. Jacob, did you suggest creating a custom node because they don’t “expose” warnings? In reality, my problem is just that it gives a warning even when everything is working perfectly. I know that this would lead the team to always think that there is something wrong…

Yes, that or design script can suppress the warning (which again, isn’t an error :wink:).

2 Likes

@jacob.small Cool, I didn’t know that! Thank you!
I’ll try this way

@jacob.small I’m Still Struggling :expressionless:


I don’t understand why, but the result = empty. I even gave up marking elements in Revit

Because you’re intending to feed a list, but haven’t told the customer node that. As a result it is tying to get all indices of true from each individual item. It’s kinda like trying to find the letter D inside the letter A, then inside the letter B. then inside the letter C, then inside the letter D… and you never find it as even though you checked the letter D it doesn’t have the letter D inside of it.

Tell Dynamo you are working with a list not an item by defining your data type for the variable and indicating that you want it to work with a list. These two documents should help:

http://designscript.io/DesignScript_user_manual_0.1.pdf

1 Like

image

Thank you, I think I understand how to do it. I just didn’t understand how I would define a level within a code block.

DesignScriptGuide.pdf page 29

2 Likes

Thank you very much!

Luupieper,

I believe the bottom line is that in a Dynamo script, all nodes are run, always.

All we can do is strategically feed null or empty data to portions of the graph that need to be ignored.

That we can do using ifs, or “this or that” or other tricks.

So, its not really controlling the flow of the graph, rather we control the flow of data downstream.

We rely on the ability of the nodes to fail graciously, that is, without breaking the overall functionality of the script.

Dynamo has improved in this sense, and many nodes will cause a warning but will keep the graph working, as stated above.

Regards

Gio

1 Like