Create FilterRule: get "ParameterId" without elements

Create FilterRule: get "ParameterId" without elements

Extraneous
Advisor Advisor
810 Views
4 Replies
Message 1 of 5

Create FilterRule: get "ParameterId" without elements

Extraneous
Advisor
Advisor

I'm writing an application for batch creating ViewFilters (ParameterFilterElement).

For creating filter I want to create FilterRule:

 

FilterRule stringRule = ParameterFilterRuleFactory.CreateEqualsRule(ParameterId, StringValue, true);

How to get "ParameterId" for shared parameter?

SDK contains two examples: 

  • for BuiltIn Parameter: 
  • ElementId ParamId = new ElementId(BuiltInParameter.FUNCTION_PARAM);
  • for SharedParameter:
Wall wall = new FilteredElementCollector(doc).OfClass(typeof(Wall)).FirstElement() as Wall;
Parameter sharedParam = wall.get_Parameter(spGuid);
ElementId sharedParamId = sharedParam.Id;

OMG: create collector for all elements in model, get one element, get parameter from this element? I think this is a bad way.

If model have no element - collector will be empty, I can't get Parameter and create Rule, other problem is possible.

 

Is there an another way to get ParameterId? Without elements and collectors, as for BuiltIn Parameter.

For example, by the Definition, BindingMap, etc. After all, manually in Revit interface I can create Rule, even if there is no element in the model.

Thanks.

 

Alexander Zuev
In BIM we trust
Facebook | Linkedin | Telegram

0 Likes
811 Views
4 Replies
Replies (4)
Message 2 of 5

Revitalizer
Advisor
Advisor

Hi,

 

since 2016, there is a SharedParameterElement class, derived from Element.

This provides a GuidValue property and also a GetDefinition() method.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 5

Revitalizer
Advisor
Advisor
Message 4 of 5

Extraneous
Advisor
Advisor
Thanks,
This method works good, but only for shared parameter. FilterRule also want to works with BuiltInParameter and ProjectParameter. Seems to be, collector and LookupParameter is only one way in this case.

Alexander Zuev
In BIM we trust
Facebook | Linkedin | Telegram

0 Likes
Message 5 of 5

sdcartmell
Enthusiast
Enthusiast

Is there any update on this?

 

"Is there an another way to get ParameterId? Without elements and collectors, as for BuiltIn Parameter.

For example, by the Definition, BindingMap, etc. After all, manually in Revit interface I can create Rule, even if there is no element in the model."

0 Likes