Code Block: Category.byName Multiple?

hi all,

I have a problem understanding the logic of Codeblock scripting.
I tried to input multiple categories in a code block script with an array, and works with both Codeblock and OOTB node.

Why can’t I use the same Array imported from an Excel cell value? Dynamo says that can’t recognise the category.

What’s the correct syntax to use from an Excel file to make this work?

Thanks!

I used this syntax to import data from excel. Data_2[5] is importing from DSOfficeData.ExcelImport

What is the warning the node produces? Can you share your graph? This will require a degree of code review and with what you are providing the picture is too incomplete to know what the issue is.

hi @JacobSmall thanks for helping! This the graph, it gets as arguments of the shared parameters columns of an Excel file. It works if Type in the “Category” column one item, I was just wondering what’s the sintax to add multiple categories at the same time. If I write an array like this scenario:

MicrosoftTeams-image (4)

works, but if I want to use a cell value from Excel (like the first screenshot) the error is “The Category is not valid”. I tried typing in the excel cell the array, with comma, with point commas, with OST values… Doesn’t work…

So, back to my original question, how to input multiple values in a Code Block? What’s the syntax?

Split of the outputs of your Data_2[4] to a watch Node first. Double check if that is actually the input you expected. The use Object.Type to make sure it is actually string data.

May you to add a parameter that does exist in “Walls” but not in “Curtain Panels”??

Hi Bjorn,
I thought the same at first, so I checked, they’re actually string data from Excel and in the input in the Block Code. Also, I said that the script doesn’t work with an “array” cell, for the same principle it shouldn’t have worked with only one category. If I input only one value it’s fine.

Sure I can, unless it’s already in the shared parameter text file. But the whole point of my script is, I wanted to give the user the chance to assign multiple categories to a parameter by writing it down on Excel. At the moment they have to enter in the project parameter menu and add them manually.

[ "Walls" , "Floors" ] ;is the value in a line of design script.

If you wanted to process a list of values from excel you would need to either do some list manipulation, or store the data in individual cells on row 5 - so A5 would be “Walls” and B5 would contain “Floors”. Can you show what the data read from excel (the results of data_2[4]; as it’s own line shifted into a watch node)?

Hi Jacob, your hint gave me the solution (even it’s not Code block straight, but maybe I can?)


I get the Data output from the Excel import, the string is split with a separator (in this case " ,") and it gets into the node. Done!

Thanks for the inspiration about the cells, but I’d like for the users to input in the template in a tidy way, and this is defenetily an option… thanks!

String.Split can definitely be called in design script if that is what you are after. Highlight the nodes you placed and right click the workspace background and select ‘Node to Code’ in the menu. This should give you some design script you can manipulate.