Logical Work


#1

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.


#2

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.


#3

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.


#4

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

#5

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


#6

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:


#7

@kvusal This can be done in a few ways

  1. Using Nodes in a current version…

  2. Using Design Script in a current version …

  3. Using Dictionary in ver 2.0 …


#8

Many thanks Vikram…