Sort selected elements by category - boolean doesn't work

Hello,
I am attempting to use the “select model elements” to use a drag window but ultimately I only want elements that are of the category “parts”. I saw this post
(Filter by category) that suggested using Element Get Category (clockwork), ==, and Filter By Bool Mask.

I have attempted to do this but at == it will not register anything but false. I have attempted to use the Categories node, a code block, and a script as the y value and none work. I also attempted to sort the elements by element type, same condition occurs. Finally I attempted to use the List.SortByFunction which will get the boolean working, and it does however if I have a large number of elements that gets selected, somewhere over 1000, I have to use List.FilterByBoolMask multiple times to slowly filter the list to just the “parts” because it appears to get overwhelmed and not work with too many elements. This direction is not ideal especially because the next step of my code I need “elements” but the List.SortByFunction output is just a string.

Any suggestions to get the == to work for the categories?



code block 3

Sort Elements by Category.dyn (567.2 KB)

Hi JCupps

The reason it is not filtering correctly is because you are trying to filter a Category by a String". Adding in
a string from object should get you where you need to.

Categories while they look like a list of “strings” are actually an object type.

See example image below. I have included some additional nodes showing output types which you may find useful on future scripts you write to debug what outputs you are dealing with.

2 Likes

Thank you @Anton_Shaw this fixed my issue. I had been looking for something similar to the String From Object but wasn’t using the right search words, a little too new at Dynamo and don’t know too many nuances just yet. Appreciate the help!