mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 10:06:47 +00:00
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
```
This commit is contained in:
@@ -1410,10 +1410,14 @@ class RemoveDrawing(bpy.types.Operator, Operator):
|
||||
drawings = [tool.Ifc.get().by_id(self.drawing)]
|
||||
|
||||
print("Removing drawings: {}".format([d for d in drawings]))
|
||||
removed_drawings = [drawing.id() for drawing in drawings]
|
||||
|
||||
for drawing in drawings:
|
||||
core.remove_drawing(tool.Ifc, tool.Drawing, drawing=drawing)
|
||||
|
||||
active_drawing_id = context.scene.DocProperties.active_drawing_id
|
||||
if active_drawing_id in removed_drawings:
|
||||
context.scene.DocProperties.active_drawing_id = 0
|
||||
|
||||
class ReloadDrawingStyles(bpy.types.Operator):
|
||||
bl_idname = "bim.reload_drawing_styles"
|
||||
|
||||
Reference in New Issue
Block a user