I am trying to create a pyrevit addin which filters elements in current view based on user selected element's parameter value. This works fine for parameters of string and double kind. But AsValueString() fails in DB.FilterStringRule probably because unit information is got lost in conversion of AsValueString type to string type in python. I have included the relevant code below:
target_parameter_value = ele.Parameter[target_parameter].AsValueString()# As value strings got converted to strings
param_id = DB.ElementId(target_parameter)
param_prov = DB.ParameterValueProvider(param_id)
param_equality = DB.FilterStringEquals() # equality class for string
value_rule = DB.FilterStringRule(param_prov,param_equality,target_parameter_value ,True)
param_filter = DB.ElementParameterFilter(value_rule)
elements = DB.FilteredElementCollector(doc)\
.OfCategory(target_category)\
.WhereElementIsNotElementType()\
.WherePasses(param_filter)\
.ToElementIds() # select category based on the rule
Is there any work around for AsValueString to work with DB.FilterStringRule or is there completely other rule for AsValueString like DB.FilterAsValueStringRule?