Dears,
can someone help me to solve this problem:
Please see screenshot for expression:
There are 4 variable and each variable have predefined values.
Now as an input I give list of variable and i want dynamo to prepare new list based on the values of these variables. (Please see Input and Output nodes)
You can use Dictionaries! I read somewhere in the forum that dictionaries will be soon available in Dynamo. For now, I can show you this very very easy code:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
key = IN[0]
dict = {'DHW 1': 7, 'DHW 2': 1, 'DHW 3': 5, 'DHW 4': 3}
v = dict[key]
#Assign your output to the OUT variable.
OUT = v
That you can edit with ease, This is a screenshot of what you need in Dynamo: Uploading…
Just double click the python node to edit it and simply copy-paste the code.
Dear Andrea, Many thanks for your support. However DHW 1, DHW 2 and etc will going to come from Revit model. I mean it will be input as list. So I need to prepare script to do this task automatically. Not to write DWH 1, DHW 2 manually.
No problem with that, we will use a cycle function. The only issue is that you need to compile your dictionary before, associating values to all your possibile keys (the DHW).
keys = IN[0]
dict = {'DHW 1': 7, 'DHW 2': 1, 'DHW 3': 5, 'DHW 4': 3}
v = [dict[i] for i in keys]
#Assign your output to the OUT variable.
OUT = v