Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FilterStringRule: expected BuiltInParameter, got SharedParameterElement

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
cgofer
451 Views, 2 Replies

FilterStringRule: expected BuiltInParameter, got SharedParameterElement

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.

2 REPLIES 2
Message 2 of 3
MarryTookMyCoffe
in reply to: cgofer

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
Message 3 of 3
cgofer
in reply to: cgofer

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

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community