Total count of item in a category, then push the Mark value with a certain order (UI version)

Hello everyone,
I am trying to implement some kind of UI to the script previously made ( with the help of some users of this amazing forum! :slight_smile: You can find the post on the previous script here.), on counting elements in a certain category and setting values in a certain order.

I will try to explain it in few words:

Basically it takes some categories, then it counts how many elements of this categories are modeled, then applies a value in the mark parameter of each, starting from the first to the last and using a sequence of numbers.

In the last few days I’ve tried to modify a little bit the phyton script, adding also letters as prefix of the number sequence and changing the number of characters accordingly.

This is an example on the air ducts and air fittings.

image

As you can see in the picture above, on the code block, the naming rule is “category” - “sequence number”, so duc for “Ducts” and duf for “Duct Fittings”, then 001, 002, etc…

This is a very useful script, but now I would like to push it one step further, like adding the UI from the data-shapes package, so users who are not familiar with the Dynamo environment don’t need to open the script, they just need to select a category from the dropdown list.

This is what I have done so far:

image

Now the question is: how would it be possible to connect the element choosen on the drop down list of the UI (for example Ducts) and push the correct parameter value related to its category? I am talking about duc if the user choose Ducts, cbt for Cable trays, etc…

Would it be possible? Do I need to connect like an external excel file on which Dynamo will read those naming conventions or its necessary to modify the code?

Any help will be more than appreciated! :slight_smile: Thanks in advance!

You will need to have a corresponding list of abbreviations that match the category names. That way the indices from both list match one another. Then you can find the index from one list and use it to select the data from the other list.

Hope this helps.

1 Like

Thank you @Azubike_Ononye it helped me to continue the script but I am facing 2 problems.

#1 - The IndexOf node returns me a “-1” value;
#2 - In this way I can not insert the “counting” part of the naming conventions. At the moment I have tried to insert a variable in the phyton code but I am still missing the “counting” operation.

Please check the images below:

#1

#2

Thanks again for the help.

@Ernesto_Pellegrino, check your levels for the index of node. They don’t match the example which @Azubike_Ononye gave you.

2 Likes

Hi @jacob.small, thanks for the reply, I tried to update the nodes as shown by @Azubike_Ononye, but still having the “-1” value as return.

I will try to do everything from scratch, probably I am connecting something in the wrong place, the only difference I see on the gif posted is that my node “IndexOf” doesen’t have the little box with the black arrows, at the element input.

image
image

Can you please show the list that is entering the “IndexOf” node? Why do you have the 0 inside curly brackets? just use 0 instead of {0}.

1 Like

You need to enable the list at level function by clicking on the > to the left of the element. :slight_smile:

1 Like

Thanks @jacob.small I didn’t know about that! It worked to return the correct value as shown by @Azubike_Ononye :slight_smile:

Now I’ll work on the “counting” part, if you have any suggestion let me know!

Have a great day!!

SOLVED! :slight_smile: All I needed to solve the “counting” part was the IF node, I tried it with multiple lists value, after the selection made by the user (as shown by @Azubike_Ononye), then I just copied few code blocks with the “phyton code” and IF the selection of the user does match the code block value, then go for it, else null!

Thanks all for the help!

1 Like