Design Script assigning values to variables

I am wanting to reassign a value to a variable. How would I go about doing this?

write it directly in a codeblck:


I want to call the num() function globally.

You are asking for the num() in the same line as you are defining the num() == num()+1, this is not possible.

You are now saying that num() is 2 variables.
(lets say X and X+1, so you are creating an infinite loop)

Just use “num() + 1;” in your code block.

1 Like

What I am wanting to do is redefine the value of the num() variable later on. Num() is initialized with a value of 1 but later on become 2 or 3 or 29 or anything.

num is not a variable, num is a function, and you are invoking it with () this means, it’s an expression, which evaluates to a number, not a variable.

1 Like

Ok let me rephrase the question. Is there a way to declare a global variable in Dynamo that can be modified at runtime?

yes, but probably not using designscript directly in a codeblock -
you could do this by using c# to declare a class which has a static property accessed by a static get/set method - then call that from a codeblock.