mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Removing sheets now works in IFC. See #1153.
This commit is contained in:
@@ -1048,16 +1048,16 @@ class EditVectorStyle(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RemoveSheet(bpy.types.Operator):
|
||||
class RemoveSheet(bpy.types.Operator, Operator):
|
||||
bl_idname = "bim.remove_sheet"
|
||||
bl_label = "Remove Sheet"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.DocProperties
|
||||
props.sheets.remove(self.index)
|
||||
return {"FINISHED"}
|
||||
def _execute(self, context):
|
||||
self.props = context.scene.DocProperties
|
||||
sheet = tool.Ifc.get().by_id(self.props.sheets[self.props.active_sheet_index].ifc_definition_id)
|
||||
core.remove_sheet(tool.Ifc, tool.Drawing, sheet=sheet)
|
||||
|
||||
|
||||
class AddSchedule(bpy.types.Operator):
|
||||
|
||||
@@ -375,7 +375,9 @@ class BIM_UL_sheets(bpy.types.UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
if item:
|
||||
row = layout.row(align=True)
|
||||
row.label(text=item.identification or "X")
|
||||
row.label(text=item.name or "Unnamed")
|
||||
split1 = row.split(factor=0.2)
|
||||
split1.label(text=item.identification or "X")
|
||||
split2 = split1.split(factor=0.8)
|
||||
split2.label(text=item.name or "Unnamed")
|
||||
else:
|
||||
layout.label(text="", translate=False)
|
||||
|
||||
@@ -82,3 +82,8 @@ def add_sheet(ifc, drawing, titleblock=None):
|
||||
|
||||
def open_sheet(drawing, sheet=None):
|
||||
drawing.open_svg(drawing.get_sheet_filename(sheet))
|
||||
|
||||
|
||||
def remove_sheet(ifc, drawing, sheet=None):
|
||||
ifc.run("document.remove_document", document=sheet)
|
||||
drawing.import_sheets()
|
||||
|
||||
@@ -117,3 +117,10 @@ class TestOpenSheet:
|
||||
drawing.get_sheet_filename("sheet").should_be_called().will_return("filename")
|
||||
drawing.open_svg("filename").should_be_called()
|
||||
subject.open_sheet(drawing, sheet="sheet")
|
||||
|
||||
|
||||
class TestRemoveSheet:
|
||||
def test_run(self, ifc, drawing):
|
||||
ifc.run("document.remove_document", document="sheet").should_be_called()
|
||||
drawing.import_sheets().should_be_called()
|
||||
subject.remove_sheet(ifc, drawing, sheet="sheet")
|
||||
|
||||
Reference in New Issue
Block a user