How can i create dictionarys? designscript/python

Hello,

How can i call a dictionary either by codeblock or dynamo? Both versions call nothing!
i can just call in python one value! I would like to have all

Is there any syntexError?

Does anybode have a clue?

Thank you, Kind Regards

Andreas

In certain versions of Dynamo, it isn’t possible to output a Python dictionary. I believe this can be done in versions using Dynamo Core 2.5 and later. In earlier versions, an alternative is to output your dictionary’s keys and values separately, and then use nodes to reconstruct your dictionary. This approach works best with a simple dictionary (if you were to use a dictionary of dictionaries, this would be much more difficult). Which version are you using?

mydict = {'key': 'value'}
OUT = mydict.keys(), mydict.values()
1 Like

1.3.4

We have some old scripts

and

2.0.3
How can i combine them ? Key : Value
we mainly work still in 2018.3.3

Hi @Draxl_Andreas

You can combine this way:

# Enable Python support and load DesignScript library
from System.Collections.Generic import Dictionary
# inputs
i = {"a":'Apple',"o":'Orange'}
# Place your code below this line
dict = Dictionary[str,object](i)
# Assign your output to the OUT variable.
OUT = dict
4 Likes


Is this just with solo string working?

i want something like this so the numbers replaced by strings

Paste your German text here.

@Draxl_Andreas Yes this exactly what it does:

1 Like

sorry i mean letter a,b,c

Yes what’s the issue with that. Could you be more specific here. May be sketch your goal.

It is not working in older versions of dynamo! My goal is to understand the concept of dictionaries, finialy to make one practical example.

This is the syntax for Designscript dictionaries in 1.3

1 Like