This is customized algorithm for "Calculation without Changing Nicknames of Evaluate's Input Every time You Change Variable's Key in the Function"
Outline
The Evaluate is always useful.
However sometimes it’s very uncomfortable. This happens when the Function
you enter into the component is very long and only a few of the Variables
are selectively included in the Function
.
In this case, you must update or enter(with clicking +
button) the desired Key(Name)
in every Nickname
section of the Evaluate’s input. For example, x
for dim
, y
for off
, and so on.
If the number of Variables
is very large, this process is very annoying. To make matters worse, if for some reason the Key
of the Variable
is changed, you need to find all theEvaluate associated with it and update the “Key(Name)” in the “Nickname” section. This is a more troublesome process.
So I wrote an algorithm that computed a Function
using only Variables
in the form Variable (Key = Value)
without being affected by Nickname
in the Evaluate.
P.S
Since this algorithm is a prototype, I assume that all calculations of functions are made with +, -, *, /
only. Therefore, more complex operators like base ^ power, max (value 1, value 2)
do not work.
Each case in the variable is Case sensitive
.
If there is a better solution without using Python
or C#
(with pure grasshopper components), i, please let me know.
If there is any error or bug, please let me know.
Reference and Huge Help
Step 1
Enter Splitters
, Function
and Variables
.
Step 2
Split function sentense
(1 item) based on the Splitters
.
Step 3
Separate each Variables
(in form of function) to Key
and Value
.
Step 4
In the splitted sentense, select the words included in the Key
and replace with the Value
corresponding to the Key
.
Join all splitted words to become single sentence. (1 item)
Step 5
Derive Result Value
based on a function sentence whose Key
is finally converted to Value
.
190910-Calculation-Without-Changing-Nickname-of-Evaluate-Component.gh (23.5 KB)