FilterStringRule: expected BuiltInParameter, got SharedParameterElement

FilterStringRule: expected BuiltInParameter, got SharedParameterElement

cgofer
Explorer Explorer
597 Views
2 Replies
Message 1 of 3

FilterStringRule: expected BuiltInParameter, got SharedParameterElement

cgofer
Explorer
Explorer

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:

3.png

 

 

 

 

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.

0 Likes
Accepted solutions (1)
598 Views
2 Replies
Replies (2)
Message 2 of 3

MarryTookMyCoffe
Collaborator
Collaborator
Accepted 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

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 3 of 3

cgofer
Explorer
Explorer

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

 

ObjetosSeleccionados.JPG

 

 

0 Likes