This commit is contained in:
Andrej730
2025-02-03 12:35:57 +05:00
parent 305b4c27b5
commit 3eaf4367ad
2 changed files with 17 additions and 11 deletions
@@ -41,7 +41,6 @@ import bonsai.core.geometry
import bonsai.core.drawing as core
import bonsai.bim.module.drawing.svgwriter as svgwriter
import bonsai.bim.module.drawing.annotation as annotation
import bonsai.bim.module.drawing.sheeter as sheeter
import bonsai.bim.export_ifc
from bonsai.bim.module.drawing.decoration import CutDecorator
from bonsai.bim.module.drawing.data import DecoratorData, DrawingsData
@@ -1691,15 +1690,8 @@ class RemoveDrawingFromSheet(bpy.types.Operator, tool.Ifc.Operator):
return True
def _execute(self, context):
reference = tool.Ifc.get().by_id(self.reference)
sheet = tool.Drawing.get_reference_document(reference)
sheet_builder = sheeter.SheetBuilder()
sheet_builder.remove_drawing(reference, sheet)
tool.Ifc.run("document.remove_reference", reference=reference)
tool.Drawing.import_sheets()
ifc_file = tool.Ifc.get()
tool.Drawing.remove_drawing_from_sheet(ifc_file.by_id(self.reference))
class CreateSheets(bpy.types.Operator, tool.Ifc.Operator):
@@ -2133,7 +2125,7 @@ class RemoveDrawing(bpy.types.Operator, tool.Ifc.Operator):
for drawing in drawings:
sheet_references = tool.Drawing.get_sheet_references(drawing)
for reference in sheet_references:
bpy.ops.bim.remove_drawing_from_sheet(reference=reference.id())
tool.Drawing.remove_drawing_from_sheet(reference)
core.remove_drawing(tool.Ifc, tool.Drawing, drawing=drawing)
# In case we removed the active drawing.
+14
View File
@@ -36,6 +36,7 @@ import bonsai.core.tool
import bonsai.core.geometry
import bonsai.tool as tool
import ifcopenshell.api
import ifcopenshell.api.document
import ifcopenshell.geom
import ifcopenshell.util.representation
import ifcopenshell.util.element
@@ -2252,3 +2253,16 @@ class Drawing(bonsai.core.tool.Drawing):
msp.add_line(*points)
finalize_dxf()
@classmethod
def remove_drawing_from_sheet(cls, reference: ifcopenshell.entity_instance) -> None:
import bonsai.bim.module.drawing.sheeter as sheeter
sheet = tool.Drawing.get_reference_document(reference)
sheet_builder = sheeter.SheetBuilder()
sheet_builder.remove_drawing(reference, sheet)
ifcopenshell.api.document.remove_reference(tool.Ifc.get(), reference=reference)
tool.Drawing.import_sheets()