|
1 | 1 | """Selects elements with no associated dimensions in current view."""
|
2 |
| -#pylint: disable=import-error,invalid-name |
| 2 | + |
| 3 | +# pylint: disable=import-error,invalid-name |
3 | 4 | from pyrevit import revit, DB, HOST_APP
|
4 | 5 | from pyrevit import forms
|
5 |
| -from pyrevit.compat import get_elementid_value_func |
6 | 6 |
|
7 | 7 | categories = {
|
8 |
| - 'Rooms': DB.BuiltInCategory.OST_Rooms, |
9 |
| - 'Areas': DB.BuiltInCategory.OST_Areas, |
10 |
| - 'Spaces': DB.BuiltInCategory.OST_MEPSpaces, |
11 |
| - 'Doors': DB.BuiltInCategory.OST_Doors, |
12 |
| - 'Windows': DB.BuiltInCategory.OST_Windows, |
13 |
| - 'Speciality Equipment': DB.BuiltInCategory.OST_SpecialityEquipment, |
14 |
| - 'Mechanical Equipment': DB.BuiltInCategory.OST_MechanicalEquipment, |
15 |
| - 'Electrical Equipment': DB.BuiltInCategory.OST_ElectricalEquipment, |
16 |
| - 'Walls': DB.BuiltInCategory.OST_Walls, |
17 |
| - 'Curtain Walls': DB.BuiltInCategory.OST_CurtainWallPanels, |
18 |
| - 'Ceilings': DB.BuiltInCategory.OST_Ceilings, |
19 |
| - 'Columns': DB.BuiltInCategory.OST_StructuralColumns, |
20 |
| - } |
21 |
| - |
22 |
| -get_elementid_value = get_elementid_value_func() |
| 8 | + "Rooms": DB.BuiltInCategory.OST_Rooms, |
| 9 | + "Areas": DB.BuiltInCategory.OST_Areas, |
| 10 | + "Spaces": DB.BuiltInCategory.OST_MEPSpaces, |
| 11 | + "Doors": DB.BuiltInCategory.OST_Doors, |
| 12 | + "Windows": DB.BuiltInCategory.OST_Windows, |
| 13 | + "Speciality Equipment": DB.BuiltInCategory.OST_SpecialityEquipment, |
| 14 | + "Mechanical Equipment": DB.BuiltInCategory.OST_MechanicalEquipment, |
| 15 | + "Electrical Equipment": DB.BuiltInCategory.OST_ElectricalEquipment, |
| 16 | + "Walls": DB.BuiltInCategory.OST_Walls, |
| 17 | + "Curtain Walls": DB.BuiltInCategory.OST_CurtainWallPanels, |
| 18 | + "Ceilings": DB.BuiltInCategory.OST_Ceilings, |
| 19 | + "Columns": DB.BuiltInCategory.OST_StructuralColumns, |
| 20 | +} |
23 | 21 |
|
24 | 22 | # make sure active view is not a sheet
|
25 | 23 | if isinstance(revit.active_view, DB.ViewSheet):
|
26 |
| - forms.alert("You're on a Sheet. Activate a model view please.", |
27 |
| - exitscript=True) |
| 24 | + forms.alert("You're on a Sheet. Activate a model view please.", exitscript=True) |
28 | 25 |
|
29 |
| -selected_switch = \ |
30 |
| - forms.CommandSwitchWindow.show( |
31 |
| - sorted(categories), |
32 |
| - message='Find undimmed elements of category:') |
| 26 | +selected_switch = forms.CommandSwitchWindow.show( |
| 27 | + sorted(categories), message="Find undimmed elements of category:" |
| 28 | +) |
33 | 29 |
|
34 | 30 | if selected_switch:
|
35 | 31 | target = categories[selected_switch]
|
36 | 32 | selection = revit.get_selection()
|
37 |
| - all_elements = DB.FilteredElementCollector(revit.doc, revit.active_view.Id)\ |
38 |
| - .OfCategory(target)\ |
39 |
| - .WhereElementIsNotElementType() |
40 |
| - all_ids = set(get_elementid_value(x.Id) for x in all_elements) |
| 33 | + all_elements = ( |
| 34 | + DB.FilteredElementCollector(revit.doc, revit.active_view.Id) |
| 35 | + .OfCategory(target) |
| 36 | + .WhereElementIsNotElementType() |
| 37 | + ) |
| 38 | + |
| 39 | + all_ids = set(x.Id.IntegerValue for x in all_elements) |
41 | 40 |
|
42 |
| - all_dims = \ |
43 |
| - DB.FilteredElementCollector(revit.doc, revit.active_view.Id)\ |
44 |
| - .OfClass(DB.Dimension)\ |
45 |
| - .WhereElementIsNotElementType() |
| 41 | + all_dims = ( |
| 42 | + DB.FilteredElementCollector(revit.doc, revit.active_view.Id) |
| 43 | + .OfClass(DB.Dimension) |
| 44 | + .WhereElementIsNotElementType() |
| 45 | + ) |
46 | 46 |
|
47 | 47 | dimmed_ids = set()
|
48 | 48 | for dim in all_dims:
|
49 | 49 | for ref in dim.References:
|
50 | 50 | if HOST_APP.is_newer_than(2023):
|
51 | 51 | dimmed_ids.add(ref.ElementId.Value)
|
52 | 52 | else:
|
53 |
| - dimmed_ids.add(get_elementid_value(ref.ElementId)) |
| 53 | + dimmed_ids.add(ref.ElementId.IntegerValue) |
54 | 54 |
|
55 | 55 | # find non dimmed
|
56 | 56 | not_dimmed_ids = all_ids.difference(dimmed_ids)
|
57 | 57 | if not_dimmed_ids:
|
58 | 58 | selection.set_to(not_dimmed_ids)
|
59 | 59 | else:
|
60 |
| - forms.alert('All %s have associated dimensions.' % selected_switch) |
| 60 | + forms.alert("All %s have associated dimensions." % selected_switch) |
0 commit comments