How does the "ElementType" thing works?

I was making a basic script to change all arrowheads of text styles in the project and it was a struggle.

I wasn’t able to retrieve arrowhead as a category, instead went through trial and error to find the ID of the Element and applied it manually.

But I know this is not the correct way:

What got me confused is that the arrowhead belongs in the “ElementType” class, with hundreds of other items. How can I sort it out?

My ultimate goal is to have a dropdown menu of all the arrowhead styles in the project, so the user can select which one to replace all families.

Any insights are welcome. Thanks.

You’re going to need to use C# for this if you’re looking for a dropdown like the Element Classes node. Haven’t done this myself but I think you would need to use something along the lines of this:

var collector = new FilteredElementCollector(doc).OfClass(typeof(ElementType)).WherePasses(new ElementParameterFilter(new FilterStringRule(provider, new FilterStringEquals(), "Arrowhead", false)));
1 Like

Thanks, Jacob.

At first, I was hoping to have that drop down in Dynamo Player. Is C# also required for this? I’m completely noob with coding (and Dynamo, fwiw), and was hoping to get familiar with OOTB and pre-made packages before going into deeper waters.

For a dropdown in player using a node marked as an input, like the OOTB Element Classes node, yes, you’ll have to get into C# unless someone has one in a package (I am not aware of one).

However if you have standard arrow names in your files you could:

  1. Place a Custom Selection node and populate the standard names.
  2. Then gather all the arrow types using the method you found before
  3. Get the name of each arrow type
  4. Test the name of each of the arrow types against the result from the Custom Selection node.
  5. Use a List.FilterByBoolMask node to filter the list of arrow types (step 2) by the boolean values (step 4)
  6. Take the item (should only be one) from the list using a List.FirstItem node.
  7. Set the parameter as before.
1 Like

I can’t thank you enough, Jacob.

I was able to do exactly what I wanted, even with the dropdown. Found my way through your suggestion and even beyond.

My solution was stablishing standardized prefixes for all arrowhead types, so they could be filtered through Element.Name. This way, if I have new types, the script does not need to change.

Another problem I found is that ElementTypes has some “null” values, so they have to be filtered in order to List.FilterByBoolMask work properly.

Finally, I used DropDown Data and MultipleInputForm++ to create a interactive window. Even better than doing it through Custom Selection.

My next step will be creating a multiple selection section in the MultipleInputForm++ so the user can choose which (or all) text styles should be changed.

Thanks again. You’re the best.

Edit: Forgot to insert some images:


image

1 Like