lunedì, agosto 22, 2016

Self-Redefinition in DesignScript

I just stumbled upon this interesting fact of the default language block you have in Code Blocks:

It looks kind of weird at first right? you would expect that the result is 1, not 2, if you do the same in a Python script you have right 1:

Note how there is only one output port on the Code Block, this is because the variable in play is called x on both lines, plus the default language block is Associative which means that each assignment is re-executed, some sort of recursion, to update all the variables values.

At first x = 0, on the second line the same variable x is then assigned to an expression x + 1, which returns x = 1, but since 1 is different form 0 it means that the value associated to x has changed so the Associativity kicks in and it re-executes the assignment that yields 1 + 1 = 2   which is totally correct in terms of DesignScript Associative language block context.

There are a couple of options to get the "standard" value 1 out of a Code Block:

Look at the number of output ports on the right side of these Code Blocks, just be thoughtful when you are using DesignScript because you need to know its own rules.

domenica, agosto 07, 2016

GraPHIcal definition of the Golden Section

One of those number deeply embedded in nature, the limit of the ratio of two consecutive members of a Fibonacci sequence, the so called number phi (1,618....) or golden section.
Just for fun, I threw in also the graphical method to extract the square root of a number, can you see it?

giovedì, agosto 04, 2016

Dynamo Letter Range

It's not exactly an ASCII table, but it can be useful to know that ranges in Dynamo Script can work on letters too, try it for yourself.