Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 53e5884

Browse files
committed
Reset active drawing id if we removed the active drawing
Previously there was an error if you remove all drawings: ``` Traceback (most recent call last): File "\addons\blenderbim\bim\module\drawing\ui.py", line 182, in draw DrawingsData.load() File "\addons\blenderbim\bim\module\drawing\data.py", line 106, in load "active_drawing_pset_data": cls.active_drawing_pset_data(), File "\addons\blenderbim\bim\module\drawing\data.py", line 134, in active_drawing_pset_data drawing = ifc_file.by_id(bpy.context.scene.DocProperties.active_drawing_id) File "\addons\blenderbim\libs\site\packages\ifcopenshell\file.py", line 326, in by_id return self[id] File "\addons\blenderbim\libs\site\packages\ifcopenshell\file.py", line 314, in __getitem__ return entity_instance(self.wrapped_data.by_id(key), self) File "\addons\blenderbim\libs\site\packages\ifcopenshell\ifcopenshell_wrapper.py", line 4517, in by_id return _ifcopenshell_wrapper.file_by_id(self, id) RuntimeError: Instance #1 077 not found ```
1 parent 9c367d1 commit 53e5884

File tree

1 file changed

+4
-0
lines changed
  • src/blenderbim/blenderbim/bim/module/drawing

1 file changed

+4
-0
lines changed

src/blenderbim/blenderbim/bim/module/drawing/operator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,10 +1410,14 @@ def _execute(self, context):
14101410
drawings = [tool.Ifc.get().by_id(self.drawing)]
14111411

14121412
print("Removing drawings: {}".format([d for d in drawings]))
1413+
removed_drawings = [drawing.id() for drawing in drawings]
14131414

14141415
for drawing in drawings:
14151416
core.remove_drawing(tool.Ifc, tool.Drawing, drawing=drawing)
14161417

1418+
active_drawing_id = context.scene.DocProperties.active_drawing_id
1419+
if active_drawing_id in removed_drawings:
1420+
context.scene.DocProperties.active_drawing_id = 0
14171421

14181422
class ReloadDrawingStyles(bpy.types.Operator):
14191423
bl_idname = "bim.reload_drawing_styles"

0 commit comments

Comments
 (0)