My goal is to test if a file exists. If it does, delete it. If not, post a popup message. But, this is executing both. (I’ve also tried ScopeIf and ScopeIf+ nodes). What am I doing wrong? Thanks!
Dynamo will reprocess your graph when the file gets deleted, hence
if File A Exists > Delete > reprocesses graph > File A no longer exists > posts a pop-up message.
Even if you invert the logic it still wont work as expected:
if File A doesn’t exist > posts a pop-up message.
but…if File A does exist:
if File A doesn’t exist > (it exists) > Delete > reprocesses graph > File A no longer exists > posts a pop-up message.
So it cant work as Dynamo’s mechanics wont allow it. You need to write a script instead, such as Python so you can monitor the change once a file is deleted and modify your evaluation accordingly (you don’t need to evaluate if a file exists if you have just deleted it for example, but with Dynamo you are forced to perform this redundant step which triggers the inconsistency in your logic).
So that’s why earlier tests would loop forever.
hmm I’m not sure thats true.
is just a call to Delete a path - … doesn’t look like a file watcher.
I would try ScopeIF again - the if node here will execute both branches as it’s a data flow construct, but ScopeIf is really an imperative node.
You’re right. I re-ran it with the ScopeIf node, and it reports null if the file exists (and deletes it without re-executing forever).
Thanks to all for your help!
I’ve learned that you must have independent branches for test, true, and false (for If or ScopedIf nodes). The image below shows the correct way, keeping branches independent.
It’s tempting to combine identical nodes, but if we use just one string for both FileExists and FileDelete, the branches would not be independent and the process would fail.