Reputation: 169
I don't understand why my code, which works fine with other revit categories:
# -*- coding: utf-8 -*-
import rpw
from rpw import revit, db, ui, DB, UI
dd1 = rpw.db.Collector(of_category='Spaces')
produces this error:
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:
Upvotes: 1
Views: 200
Reputation: 8294
What target type? If your target type is rooms, the explanation is provided by The Building Coder discussion of Collecting all Rooms on a Given Level: You can't collect Room
elements directly, because they are an artificial construct of the Revit API and do not exist natively inside of Revit. Therefore, you need to collect SpatialElement
objects instead, the Room
parent class, and post-process the results, e.g., cast them to rooms. See also Accessing Room Data and Filtering for a Non-Native Class.
Upvotes: 2