【问题标题】:using python to access an element's parameter value through RPW使用python通过RPW访问元素的参数值
【发布时间】:2019-01-23 21:51:00
【问题描述】:

我不确定我做错了什么。我的代码是

# -*- coding: utf-8 -*-
from rpw import revit, db, ui, DB, UI
import clr

# Import RevitAPI
clr.AddReference("RevitAPI")

dd1 = db.Collector(of_category='Data Devices') 

for d in dd1:
    o=db.Element(d)
    print ("Value of comments parameter = ", o.parameters['Comments'].value)

我的错误信息是:

File "C:\Program Files\pyRevit-Master\pyrevitlib\rpw\db\parameter.py", line 70, in __getitem__
rpw.exceptions.RpwParameterNotFound: parameter not found [element:2367981]:[param_name:Comments]

但是我知道这个参数是每个数据设备元素的一部分。

【问题讨论】:

  • 我认为问题出在我的收集器声明上,如果我打印 dd1 我得到:
  • 所以看起来声明 dd1 = db.Collector(of_category='Data Devices') 正在收集作为 Revit 模型中的实例和 FamilyTypes 集合中的实例的数据设备?

标签: python revit-api pyrevit


【解决方案1】:

我将dd1 = db.Collector(of_category='Data Devices')这一行修改为dd1 = rpw.db.Collector(of_category='Data Devices', of_class='FamilyInstance'),从而解决了问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-27
    • 2017-06-24
    • 2011-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多