Hi,
Sorting is something that I haven’t interacted with all that much with Dynamo.
I have a list of parameter names that are chosen by myself via Data-Shapes:
I then want to determine what UnitType these parameters are, but when I run them through the FamilyParameter.Properties node, the order changes:
I am trying to sort the UnitType output to match the order of the parameter names from the first image. Could anyone point me in the direction of what nodes to use? I played around with sortbyfunction and list.sort but couldn’t get what I was after.
Thanks!
Can you show us the rest of the inputs and the node previews for what you have shown there? I’m guessing your ListAnyTrue
node is the issue. Since you’re looking for any true value in the comparisons, you’re getting the matching values back in the order that they appear in the off-screen list. If you want to match the order of the codeblock values you’d have to use the FilterByBoolMask
node directly with list levels.
EDIT: You seem to be prioritizing the list order of the original (off-screen) list, which gives you sublists matching the params you’re looking for, but then List.AnyTrue
simplifies that back to matching the original list. Your filtered list now matches the original list order.
You essentially want to do the opposite. By prioritizing the param list order (via list levels) the sublists now represent each param name in order. So you can now filter each sublist (again, with list levels) to return your filtered values in the same order.
Hi Nick,
Thanks for taking the time!
My workflow starts here:
I collect all the Parameters in the family document.
Then I run it through datashapes to select the parameters that I would like to map.
The code block represents the parameters that were ticked from the list:
From there I need to get the actual parameters so that I can feed them into the clockwork node, not the parameter names… This is what I am doing when I flatten the list coming from the “FamilyParameters” output. I’m using the AnyTrue node so that I can pull the Actual Parameters out of the initial node via the FilterByBoolMask.
I assumed that the FilterByBoolMask node (Which now contains the parameters) and the Code block parameter names would be in the same order? But then when it goes through Clockwork you can see the order is changed. And you are right, it is going back to the priority coming out of the FamilyDocument.Parameters node…
My goal here is to get the unit types of the parameters in the same order as the parameters coming out of the very first list, which is the “FamilyDocument.Parameters” list.
Think about it this way: ListAnyTrue
is giving you a single boolean. It doesn’t care which params were matching. You’re losing any sense of order by doing this.
It may be a little counterintuitive, but you want your boolean list to match the list of (parameter) elements, not the list of names. Each sublist will then align with the parameter name. Meaning the list of elements matching “Apparent Load” will be the first sublist, the list of elements matching “Description” will be the second sublist, and so on. That way you can filter the elements by each sublist and maintain the parameter name order.
FYI - The difference between filtering parameter elements and parameter names is a moot point here. The structure is the same and they both represent the same thing. You don’t need to worry about that.
Thanks very much for the explanation Nick. What you are saying makes sense and I will do the modifications tomorrow at work.
Have a great rest of your day and thanks again!!
1 Like