Implement undo for type, unit, and void operators. See #1475.

This commit is contained in:
Dion Moult
2021-07-05 15:03:50 +10:00
parent 4f5d4def1e
commit 41bc109556
3 changed files with 22 additions and 0 deletions
@@ -57,9 +57,13 @@ class AssignType(bpy.types.Operator):
class UnassignType(bpy.types.Operator):
bl_idname = "bim.unassign_type"
bl_label = "Unassign Type"
bl_options = {"REGISTER", "UNDO"}
related_object: bpy.props.StringProperty()
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
def _execute(self, context):
self.file = IfcStore.get_file()
related_objects = (
[bpy.data.objects.get(self.related_object)] if self.related_object else bpy.context.selected_objects
@@ -80,6 +84,7 @@ class UnassignType(bpy.types.Operator):
class EnableEditingType(bpy.types.Operator):
bl_idname = "bim.enable_editing_type"
bl_label = "Enable Editing Type"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
bpy.context.active_object.BIMTypeProperties.is_editing_type = True
@@ -101,6 +106,7 @@ class DisableEditingType(bpy.types.Operator):
class SelectSimilarType(bpy.types.Operator):
bl_idname = "bim.select_similar_type"
bl_label = "Select Similar Type"
bl_options = {"REGISTER", "UNDO"}
related_object: bpy.props.StringProperty()
def execute(self, context):
@@ -7,8 +7,12 @@ from ifcopenshell.api.unit.data import Data
class AssignUnit(bpy.types.Operator):
bl_idname = "bim.assign_unit"
bl_label = "Assign Unit"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
def _execute(self, context):
ifcopenshell.api.run("unit.assign_unit", IfcStore.get_file(), **self.get_units())
Data.load(IfcStore.get_file())
return {"FINISHED"}
@@ -8,10 +8,14 @@ from ifcopenshell.api.context.data import Data as ContextData
class AddOpening(bpy.types.Operator):
bl_idname = "bim.add_opening"
bl_label = "Add Opening"
bl_options = {"REGISTER", "UNDO"}
opening: bpy.props.StringProperty()
obj: bpy.props.StringProperty()
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
def _execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
opening = bpy.data.objects.get(self.opening)
opening.display_type = "WIRE"
@@ -85,10 +89,14 @@ class RemoveOpening(bpy.types.Operator):
class AddFilling(bpy.types.Operator):
bl_idname = "bim.add_filling"
bl_label = "Add Filling"
bl_options = {"REGISTER", "UNDO"}
opening: bpy.props.StringProperty()
obj: bpy.props.StringProperty()
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
def _execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
opening = bpy.data.objects.get(self.opening) if self.opening else context.scene.VoidProperties.desired_opening
self.file = IfcStore.get_file()
@@ -108,9 +116,13 @@ class AddFilling(bpy.types.Operator):
class RemoveFilling(bpy.types.Operator):
bl_idname = "bim.remove_filling"
bl_label = "Remove Filling"
bl_options = {"REGISTER", "UNDO"}
obj: bpy.props.StringProperty()
def execute(self, context):
return IfcStore.execute_ifc_operator(self, context)
def _execute(self, context):
obj = bpy.data.objects.get(self.obj) if self.obj else bpy.context.active_object
self.file = IfcStore.get_file()
ifcopenshell.api.run(