mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-15 18:14:08 +00:00
You can now delete unit assignments
This commit is contained in:
@@ -4,6 +4,8 @@ from . import ui, prop, operator
|
||||
classes = (
|
||||
operator.AssignUnit,
|
||||
operator.LoadUnits,
|
||||
operator.DisableUnitEditingUI,
|
||||
operator.RemoveUnit,
|
||||
prop.Unit,
|
||||
prop.BIMUnitProperties,
|
||||
ui.BIM_PT_units,
|
||||
|
||||
@@ -88,3 +88,31 @@ class LoadUnits(bpy.types.Operator):
|
||||
props.is_editing = True
|
||||
# bpy.ops.bim.disable_editing_unit()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class DisableUnitEditingUI(bpy.types.Operator):
|
||||
bl_idname = "bim.disable_unit_editing_ui"
|
||||
bl_label = "Disable Unit Editing UI"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.BIMUnitProperties.is_editing = False
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class RemoveUnit(bpy.types.Operator):
|
||||
bl_idname = "bim.remove_unit"
|
||||
bl_label = "Remove Unit"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
unit: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMUnitProperties
|
||||
self.file = IfcStore.get_file()
|
||||
ifcopenshell.api.run("unit.remove_unit", self.file, **{"unit": self.file.by_id(self.unit)})
|
||||
Data.load(self.file)
|
||||
bpy.ops.bim.load_units()
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -26,8 +26,8 @@ class BIM_PT_units(Panel):
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="{} Units Found".format(len(Data.unit_assignment)), icon="SNAP_GRID")
|
||||
if self.props.is_editing:
|
||||
row.operator("bim.add_group", text="", icon="ADD")
|
||||
row.operator("bim.disable_group_editing_ui", text="", icon="CANCEL")
|
||||
# row.operator("bim.add_unit", text="", icon="ADD")
|
||||
row.operator("bim.disable_unit_editing_ui", text="", icon="CANCEL")
|
||||
else:
|
||||
row.operator("bim.load_units", text="", icon="GREASEPENCIL")
|
||||
|
||||
@@ -49,3 +49,4 @@ class BIM_UL_units(UIList):
|
||||
row = layout.row(align=True)
|
||||
row.label(text=item.unit_type or "No Type", icon=item.icon)
|
||||
row.label(text=item.name or "Unnamed")
|
||||
row.operator("bim.remove_unit", text="", icon="X").unit = item.ifc_definition_id
|
||||
|
||||
Reference in New Issue
Block a user