Element's weight calculation


#1

Hi, All

I’m studying Crane Position Optimization with the Autodesk lecture below.
http://au.autodesk.com/au-online/classes-on-demand/class-catalog/2016/revit/cs21553#chapter=0

In this material, there is a part to calculate each element’s weight.
image

It ran very well before updating Dynamo.
After an update, It suddenly doesn’t work.

Anyone who knows what happened?
Is there any method to calculate each element’s weight?


#2

Can you show some watch nodes of the data which you are putting into the codeblock (from all five sources)?


#3

Judging from this:
image
If I’m not wrong you’re using dictionaries here.
At least this would be one way to define a dictionary in Dynamo prior to version 2.0
But in 2.0 the square brackets replace the curly brackets for defining lists and hence the error.
so a list {a,b,c} in Dynamo 1.3 would look like [a,b,c] in 2.0
I am clueless though about how would you define a dictionary now, I still don’t have the newest version.


#4

Hi, Virtor

I changed square brackets into the curly brackets.
but another problem comes out.

Do I have to change another thing?


#5

I don’t think you understand what Victor said…

What is being done in your first image (v 1.3) is that a dictionary is being created and values added.

What, but in version 2.0 the square brackets means that lists are being created.

By changing to curly brackets in 2.0 you simply change to an non-existing syntax. You should rather try and investigate if you can create dictionary values another way. Or look at the outputs of the 1.3 version and see if you can match this in 2.0. (Assuming the dictionary functionality is not used further down stream).


#6

What @Jonathan.Olesen said is correct.
Assuming python nodes work in the same way they do in earlier versions (still I haven’t put my hands on Dynamo 2) you can substitute your code block with 2 lines of python code:

dict = {"Walls" : IN[0],"Floors" : IN[1],"Structural Columns" : IN[2],"Structural Framing" : IN[3]}
OUT = [dict[i] for i in IN[4]]

you’ll need 4 inputs in the same way as you do with the code block:


#7

Info on dictionaries can be found here:

http://dynamobim.org/to-dynamo-2-0-and-beyond/


#8

As stated above, you need to use Dictionaries in v 2.0 and above. This is how you can modify the script. Delete the code block and replace it by:

I attached the modified script for the single analysis.SingleCraneAnalysis - 01 Situation Calculation.dyn (155.2 KB)


#9

I just wanted to share that you can use dictionaries pre Dynamo 2.0.x. You do have to define them in a code block though.


#10

Just for info, I have coded a set of nodes for dictionaries there is available for the Dynamo 1.3 versions.

I have adjusted mine so they work as the OOTB nodes do in the dynamo 2.0 versions. Since I have deprecated mine in the Dynamo 2.0 versions, have I added migration for these nodes so you can open the graphs made in 1.3 series in Dynamo 2.0 series without even notice it!

In other words, my nodes for 1.3 works seamlessly together with the OOTB nodes in 2.0 :slight_smile: