Dividing script?

Hello,

I’ve just made a script that’s writing data from excel to dynamo into Revit with a lot of help from some of you guys in here. The purpose with the script is to give all the elements in the model a given parameter from the excel sheet.

The thing is that the script is running pretty slow. Do you think I should divide the script into multible pieces like, one script for inner walls and another for outer walls and so on? Interesting to hear some thoughts about this.

Thanks,
Rickard

very difficult to say without any documentaion…

quoting @Konrad_K_Sobon

Zoom in on a few nodes and then use the camera (upper right corner in Dynamo). Using this method will it be possible to read your graph. Provide also the dynamo graph as well (.dyn file).

NS8360_5.dyn (1.7 MB)

What’s your end goal ? how is the data structured in the excel file ? depending on what are you distributing the data structure ? Please elaborate. I already see in your close up a repetition which i don’t know the reason for.

Test.xlsx (53.0 KB)

This can be heavily cleaned… it is very messy what you have done. I will try to clean a corner of you script and then reveal it as fast as possible, just browsing around in you graph is a nightmare…

Hehe, thanks erfajo. I’m new to this so I’m thankful for all the help I can get! :slight_smile:

So here goes the method…
In the corner I have cleaned, you read the data over and over again, once you had them, you even reread it just to get another row… that was almost killing my machine.
Read only your data once!


Home.dyn (22.8 KB)

It is of course ok to use custom packages, but for setting type parameters you only need to add the ‘Element.ElementType’ before the setter (the example in the top right corner of the graph). I would also have loved to get rid of @Dimitar_Venkov ‘ToString’ node, but his node is simply that much more clever than the OOTB node.

You should consider how your excel sheet is designed, that could be done more efficient. It looks like you have used a lot of time in frosting on the cake and not built it with data retrieve in mind.

This is great help!

I’m going to give this a go and post the script again and see what you think.

Thanks alot!

NS8360_7.dyn (68.5 KB)

I had a look at the script and the list handling with your method makes much more sense!

I’ve added a new .dyn file. Is this a better way to add new wall types? In my mind this looks good. The script runs sooooo much faster now!

About the excel sheet I guess I just have to keep working. I probably need to learn more about transfering data effective :slight_smile:

Just by the file size can I see the difference, going from 1.7 Mb to 68.5 Kb tells me you are on the right track. Then I will repeat what I wrote previously!

Read only your data once! :slight_smile:

When you collect your walls, all elements of category and find the element name, that part should only happen once, since it is the exact same you are doing four times. get rid of redundancy :slight_smile:

Remove the “use for type parameter” block you are not using it at all :slight_smile:

Finally… share your graph as an image when you have revised it (and your .dyn file)

by the way… It is good custom to acknowledge the ‘solution’ by marking it :slight_smile:

Getting closer! :slight_smile:

This is so much better from where I started! This is try number 10 :slight_smile:

Big Thanks to erfajo for being so helpful! I’ve really learned alot!
NS8360_10.dyn (220.7 KB)

looks good, but check this… and I will try a solution that could make it even more efficient
NS8360_10_erfajo.dyn (225.7 KB)

That’s actually beautiful… like for real! :slight_smile:

try if this works… this should include all


NS8360_11_erfajo.dyn (26.6 KB)

the graph include the below code:

#Excel index input, must be of same length!
idx1 = IN[0]
idx2 = IN[1]

#Revit input list, has same length!
elements = IN[2]
names = IN[3]

#Instantiate output lists
result = [[[] for j in range(len(idx1))] for i in range(3)]

#Core data processing
for i, name in enumerate(names) :
	for j, _ in enumerate(idx1) :
		s = '_YV ' + format(j + 1, '02')
		if s in name :
			result[0][j].append(elements[i])
			result[1][j].append(idx1[j])
			result[2][j].append(idx2[j])
		else :
			continue

#Output
OUT = result

I can just say thank you again! Couldn’t have learn all this just browsing around.