I am currently working with lists, trying to set type parameter values based on type keys. For keys and values I have an Excel file I read to create key and value lists.
The goal is to identify elements in the project carrying a specific value in a type parameter (key). Based on this key the elements should be sorted and the values from the Excel file assigned to another type parameter.
Solved that part - [It seems like it is what I want to do but I can’t get it to work because I can not find the “recorder” node in my Dynamo 1.0. Does anyone know if it’s from a custom package or maybe just renamed?
(I do have Lunchbox, Clockwork, ArchiLab, SpringNodes, SteamNodes)]
Below you find what the definition currently looks like. I think it’s mainly missing the “recorder” node. However I am happy for any advice on improvements as I am still struggling a bit to fully understand the list behaviour:
Welcome to the community, @mrck!
A suggestion would be to search for the Reorder instead of the Recorder node and you’ll be better off. I’m sure someone can look into your script as well.
Jostein,
thank you for pointing that out.
Kind of a bad start with this stupid mistake.
Well … However now I got this part running, but still need to order the elements based on their key to assign the right values from the excel file to the elements retrieved from the project. As you can see the order of the keys from Excel and the ones I get from the project are different (key of project/excel in highlight nodes)
I tried messing around with sorting the keys (string to number and sorting). Couldn’t find a way to just order string alphabetically. But even if it worked, still I read more keys from the Excel file than are actually in the project.
Can I match just the ones existing in the project with the corresponding values from Excel?
No worries! However if you can provide som example files that highlights your issue it would make it much easier to give advice, instead of rebuilding everything from skratch, and you probably will get help sooner!
In the end goal is to push several parameters based on the key value, but I guess that will then just be the same set.parameter routine copied several times. For the moment however I am just using columns A and B from the Excel file.
Vikram,
thank you very much for your reply.
Your definition looks super straightforward and I just tried it.
Unfortunately I am getting an error. Error is because the length of the list of elements/keys from the project is longer than the list of keys from Excel. So in the end the indices just don’t exist in the key list I read from Excel.
Not sure if the fact that I am working with Type parameters makes a difference too. Any suggestion on how to fix the error or other solutions?
Your inital proposal works perfectly after I added key entries to the Excel setting values to 0 for those keys. This way I avoid the error and can set the right values, at least for the moment that will do.
The alternate suggestion will not improve the script.
I’d say extending the excel sheet to include all keys with associated dummy keys (as you seem to have now done) is the way to proceed.