If I use the node CurrentLayer, it takes the value from the drawing at that moment. Changing it will not update the script (while other nodes do like selecting objects from a layer). If I place a new node CurrentLayer, I have different values in the nodes.
Is there a reason why this node is not updated to the expected value?
I believe that node doesn’t update without forcing a toggle. I think this is by design but @Frank_Huang can confirm.
I believe that a work-around is to place a dummy if statement toggle before it, using Design Script because why get complicated. Let me know if this doesn’t work in a code block, where the output goes into the Document.CurrentLayer node.
Toggle ? Doc : Doc
The ‘toggle’ input should be wired to a Boolean node. The Doc input to the Document.Current node.
Any flip of the toggle switch will update everything down stream, despite the fact that nothing new has been passed along (both the true and the false pass the same data, but Dynamo doesn’t know that).
The ‘Run Preview’ feature is a great way to visualize this.
@JacobSmall @Anton_Huizinga you are right. we didn’t force it to update. in Automatic mode, reconnect the document input, it will update to the right value. This is as designed at this moment.
if you have any thought on the impact of this behavior, let me know.
It does not have much impact, Most people will just run a script and not switch layers while in script mode.
If it can be changed in the future to the expected output (or change the description to “Current when connected” ) I’ll be happy. On the other hand, other nodes also not change (math.random) so I’m not sure what is the best.
The toggle switch works great, maybe there are other solutions (i.e. activating the script editor, can that be accessed with DS?) else the true/false switch is a good option to trigger static functions.