Logical Work

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)

Thanks.

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
1 Like

Dear Andrea,
It is also will not solve my problem. If possible I prefer not to use python script on solution.

It seems to me that my code does exactly what you asked in your screenshot. o.O

Anyway, if you don’t want to use a python node, Wait some other answers :wink:

1 Like

@kvusal This can be done in a few ways

  1. Using Nodes in a current version…
    20170219-1

  2. Using Design Script in a current version …
    20170219-2

  3. Using Dictionary in ver 2.0 …

6 Likes

Many thanks Vikram…

1 Like