简体   繁体   English

AsValueString() 上的 DB.FilterStringRule 失败

[英]DB.FilterStringRule on a AsValueString() Fails

I am trying to create a pyrevit addin which filters elements in current view based on user selected element's parameter value.我正在尝试创建一个 pyrevit 插件,它根据用户选择的元素的参数值过滤当前视图中的元素。 This works fine for parameters of string and double kind.这适用于 string 和 double 类型的参数。 But AsValueString() fails in DB.FilterStringRule probably because unit information is got lost in conversion of AsValueString type to string type in python.但是 AsValueString() 在 DB.FilterStringRule 中失败可能是因为在 python 中将 AsValueString 类型转换为字符串类型时单元信息丢失了。 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? AsValueString 是否有任何解决方法可以与 DB.FilterStringRule 一起使用,或者 AsValueString 是否有完全其他的规则,例如 DB.FilterAsValueStringRule?

You cannot use AsValueString with FilterStringRule at all.您根本不能将AsValueStringFilterStringRule一起使用。 The latter interacts with the raw Revit database values.后者与原始 Revit 数据库值交互。 The former converts the raw Revit database value to a user visible display string.前者将原始 Revit 数据库值转换为用户可见的显示字符串。 Please use the Parameter value accessors to read the raw database values instead:请使用Parameter值访问器来读取原始数据库值:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM