I’m amazed at how little can be found regarding this, and I’m having a really hard time to find what I need.
In short, I want to be able to take Builtin parameter like ALL_MODEL_MARK, and determine to which categories it is bound.
The larger scope is that I want to create a ElementFilter that has the exact same categories assigned to it as the builtinparameter has.
I’ve looked through the ParameterBindings object, but it only has user-defined parameters.
And going through the definition of the Parameter is also just a dead end.
Anybody have any ideas?
It’s been a while since i worked on the code but i found a solution to it a few months back.
the code is far from perfect but i works in it basic form.
My goals was to write a methode that could retrieve any parameter value from any parameter that belongs to a category or element.
In that code this piece gets me the list parameters i was looking for:
The next methode makes a list of the parameters by there names:
def CommonParametersToNameIdList(common_parameters):
NameIdList = []
for param_id in common_parameters:
parameter_definition = doc.GetElement(param_id)
if parameter_definition is not None:
NameIdList.append((parameter_definition.Name,param_id))
else:
# Attempt to convert the ElementId to a BuiltInParameter
built_in_param = Enum.ToObject(BuiltInParameter, param_id.IntegerValue)
param_name = LabelUtils.GetLabelFor(built_in_param)
NameIdList.append((param_name,param_id))
return NameIdList
After this my code goes a bit too deep to and too messy to share it in a propper way, it’s also a bit too busy for me to make a long post about it.
I promise i will do so in augustus when i’m back from vacation and have more time for programming ;).
hopefully this code snippetes already clear some air for you both.
Let me know if your still stuck and i’ll see next week if i can clean up the rest of the code that i wrote.
Hmm, I have not run into that ParameterElementUtils in my searches (I did run into ParameterUtils >_> which I though would have some methods like this.)
Thank you for that
But alas, getting all categories of a builtin still does not appear to be in the cards.
I quickly tried checking the other functions available from parameterElementUtils, but to no success
from System import Enum
cats = ParameterFilterUtilities.GetAllFilterableCategories()
params = ParameterFilterUtilities.GetFilterableParametersInCommon(doc, cats)
for p in params:
enumObj = Enum.ToObject(BuiltInParameter, p.IntegerValue)
# sadly this only a single parameter
i think you can get your list if you first check all categories for there parameters and then transpose this list so you would get a categories by parameter.
(transpose → talking in dynamo terms here. read: making your values keys or the other way around ;))
however this way of doing this seems to be ineffecient tho, if that is a concern…