Hi everyone,
These are my first lines in python working with the Revit API. I have looked for information in different forums and I cannot find the answer or I am not able to understand it.
I have made the following script that allows me to look up a value in a Built In Parameter.
# Test3
bip=BuiltInParameter.ALL_MODEL_MARK
provider=ParameterValueProvider(ElementId(bip))
evaluator=FilterStringEquals()
value="2"
rule=FilterStringRule(provider,evaluator,value,False)
filter=ElementParameterFilter(rule,True)
muros=FilteredElementCollector(doc).WhereElementIsNotElementType().WherePasses(filter).ToElementIds()
uidoc.Selection.SetElementIds(muros)
When I try to extrapolate the code to a shared parameter:
# Test4
lup=SharedParameterElement.Lookup(doc,Guid('7b587ac7-681e-4b97-9e56-94ea81b9bf47'))
provider=ParameterValueProvider(ElementId(lup))
evaluator=FilterStringEquals()
value="aa"
rule=FilterStringRule(provider,evaluator,value,False)
filter=ElementParameterFilter(rule,True)
muros=FilteredElementCollector(doc).WhereElementIsNotElementType().WherePasses(filter).ToElementIds()
uidoc.Selection.SetElementIds(muros)
The FilterRuleString provider shows the following error:
I understand that I should use another rule / filter but I have not found the correct way to do it. I have tried with: LookupParameter (), get_parameter (), GetParameters () to get the values and FilterStringEquals (prov, evaluator, value, False), ParameterFilterRuleFactory.CreateEqualsRule (prov, value, False) for rule creation without getting the desired result.
Thansk in advance.
Solved! Go to Solution.
Solved by MarryTookMyCoffe. Go to Solution.
this is where there can be a problem
provider=ParameterValueProvider(ElementId(lup))
change it to
provider=ParameterValueProvider(lup.Id)
ElementId take
public ElementId(BuiltInParameter parameterId);
public ElementId(BuiltInCategory categoryId);
public ElementId(int id);
and you give it a sharedparameterElement
Thank you very much, I could have sworn that I had already tried it, but it would be in a trial version that would fail for another reason.
Thanks again
Can't find what you're looking for? Ask the community or share your knowledge.