我不明白为什么我的代码可以与其他revit类别配合使用:

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

dd1 = rpw.db.Collector(of_category='Spaces')


产生此错误:

IronPython Traceback:
Traceback (most recent call last):
 File "C:\Users\USTL02870\Dropbox\WSP Project local folders\PyRevit custom extensions folder\BTS-NY-BETA.extension\BTS-NY-BETA.tab\Beta Tools.panel\test1.pushbutton\beta1_script.py", line 16, in
 File "C:\Users\USTL02870\AppData\Roaming\pyRevit-Master\pyrevitlib\rpw\db\collector.py", line 445, in __init__
 File "C:\Users\USTL02870\AppData\Roaming\pyRevit-Master\pyrevitlib\rpw\db\collector.py", line 464, in _collect
 File "C:\Users\USTL02870\AppData\Roaming\pyRevit-Master\pyrevitlib\rpw\db\collector.py", line 78, in apply
 File "C:\Users\USTL02870\AppData\Roaming\pyRevit-Master\pyrevitlib\rpw\db\collector.py", line 190, in process_value
 File "C:\Users\USTL02870\AppData\Roaming\pyRevit-Master\pyrevitlib\rpw\utils\coerce.py", line 149, in to_category
 File "C:\Users\USTL02870\AppData\Roaming\pyRevit-Master\pyrevitlib\rpw\db\builtins.py", line 134, in fuzzy_get
 File "C:\Users\USTL02870\AppData\Roaming\pyRevit-Master\pyrevitlib\rpw\db\builtins.py", line 107, in get
rpw.exceptions.RpwCoerceError: Could not cast value:spaces to target_type:

最佳答案

什么目标类型?如果您的目标类型是房间,则说明由The Building CoderCollecting all Rooms on a Given Level讨论提供:您不能直接收集Room元素,因为它们是Revit API的人为构造,并且本身并不存在于Revit内部。因此,您需要代替SpatialElement父类收集Room对象,并对结果进行后处理,例如将其投射到房间中。另请参见Accessing Room DataFiltering for a Non-Native Class

关于python - Revit API收集器:无法将value:spaces强制转换为target_type:,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54617118/

10-12 17:50