Common Python dictionary in dynamo

Hey guys,

I’m working at a very large script at my job for building customiseable buildings from dynamo, we’re pulling the configurations of the buildings from an excel spreadsheet, so far so good.

now i’m trying to make it simpler by using something like a dictonary of it’s parameters in which the values are pulled from excel. do you have any ideas for this? im trying to do it in a python script, but it doesnt seem i can call the parameters from anothe pythonscript node, doe a dictionary have to be in the same node as the call?

Just need something to get me going.

the error in the second nod is ;

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 7, in
NameError: name ‘building_dict’ is not defined

Thanks, Johannes

image

image

You aren’t defining the dictionary as the output in your first node, but are instead outputting a zero.

Might be easier to use the OOTB excel read nodes here.

Thankyou for your reply,
Reading the excel isn’t really a problem, making a dictionary of the values is, how would i put the dict as OUT?

right now your last line of code is:

OUT = 0

You want that out value to be your building dictionary, so you want your last line to read

OUT = whateverthevariableforyourbuildingdictionaryis

Also, even for building the dictionary, you’ll likely benefit from the OOTB node for this.

  1. I am not sure that Dynamo will correctly handle the dictionary in python format as it has its own method for dealing with this data class.

  2. You’ve asked a fairly basic Python for Dynamo question, so you may benefit from the more immediate feedback and data review available with visual programming instead of the hybrid.

2 Likes

I second Jacob here. From experience, I believe that Dynamo do not handle well at all Python dictionaries.

1 Like

Ah okay, thanks anyway guys, I’ll have to think of another way then.

Skip the python and generate your dictionary using out of the box nodes perhaps?

My intention was to limit the amount of wires running through the script, I’ll try to limit it using ootb but I’m just looking into the options of coding some stuff to make it better

Ah! An in-line function using design script in a code block would work as well as python in that case. Could even read the excel file in the same line. If you post your graph as it stands to this point we can help you produce said code.

As one would Jesse Pinkman from Breaking Bad would say :

“Those in-line functions using design script are dope yo !”

Seriously, since I started writing in DesignScript using only those in-line functions and Python Scripts, my graphs work incredibly well :slight_smile: (Helped a lot regarding the usage of the RAM)

Hey @Johannes_Holwerda ,

Just wondering if you’ve considered ‘node to code’?


image
image

Hope that helps,

Mark

What is an in-line function?

seems related https://github.com/DynamoDS/Dynamo/pull/9296

Calling multiple functions in the same line. Something like this (not at the cpu so this may not work):

Line.ByStartPointEndPoint(Point.ByCoordinates(0,0,0),PointByCoordinates(10,0,0));

Normally you would have 3+ nodes there, meaning 3 hits on the ram, but this results in a single one, and only the bit you care about too.

2 Likes