mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Implement undo for model operators. See #1475.
This commit is contained in:
@@ -20,13 +20,6 @@ classes = (
|
||||
pie.OpenPieClass,
|
||||
pie.PieUpdateContainer,
|
||||
pie.PieAddOpening,
|
||||
pie.AssignIfcWall,
|
||||
pie.AssignIfcSlab,
|
||||
pie.AssignIfcStair,
|
||||
pie.AssignIfcDoor,
|
||||
pie.AssignIfcWindow,
|
||||
pie.AssignIfcColumn,
|
||||
pie.AssignIfcBeam,
|
||||
pie.VIEW3D_MT_PIE_bim,
|
||||
pie.VIEW3D_MT_PIE_bim_class,
|
||||
)
|
||||
|
||||
@@ -190,12 +190,16 @@ def add_object(self, context):
|
||||
class BIM_OT_add_object(Operator):
|
||||
bl_idname = "mesh.add_door"
|
||||
bl_label = "Dumb Door"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
overall_width: FloatProperty(name="Overall Width", default=0.85)
|
||||
overall_height: FloatProperty(name="Overall Height", default=2.1)
|
||||
depth: FloatProperty(name="Depth", default=0.2)
|
||||
|
||||
def execute(self, context):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
add_object(self, context)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -101,6 +101,9 @@ class BIM_OT_add_object(Operator):
|
||||
total_v: IntProperty(name="Number of V Grids", default=3)
|
||||
|
||||
def execute(self, context):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
add_object(self, context)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -10,74 +10,15 @@ class OpenPieClass(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AssignIfcWall(bpy.types.Operator):
|
||||
bl_idname = "bim.assign_ifc_wall"
|
||||
bl_label = "IfcWall"
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.bim.assign_class(ifc_class="IfcWall")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AssignIfcSlab(bpy.types.Operator):
|
||||
bl_idname = "bim.assign_ifc_slab"
|
||||
bl_label = "IfcSlab"
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.bim.assign_class(ifc_class="IfcSlab")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AssignIfcStair(bpy.types.Operator):
|
||||
bl_idname = "bim.assign_ifc_stair"
|
||||
bl_label = "IfcStair"
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.bim.assign_class(ifc_class="IfcStair")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AssignIfcDoor(bpy.types.Operator):
|
||||
bl_idname = "bim.assign_ifc_door"
|
||||
bl_label = "IfcDoor"
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.bim.assign_class(ifc_class="IfcDoor")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AssignIfcWindow(bpy.types.Operator):
|
||||
bl_idname = "bim.assign_ifc_window"
|
||||
bl_label = "IfcWindow"
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.bim.assign_class(ifc_class="IfcWindow")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AssignIfcColumn(bpy.types.Operator):
|
||||
bl_idname = "bim.assign_ifc_column"
|
||||
bl_label = "IfcColumn"
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.bim.assign_class(ifc_class="IfcColumn")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AssignIfcBeam(bpy.types.Operator):
|
||||
bl_idname = "bim.assign_ifc_beam"
|
||||
bl_label = "IfcBeam"
|
||||
|
||||
def execute(self, context):
|
||||
bpy.ops.bim.assign_class(ifc_class="IfcBeam")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class PieAddOpening(bpy.types.Operator):
|
||||
bl_idname = "bim.pie_add_opening"
|
||||
bl_label = "Add Opening"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
if len(context.selected_objects) == 2:
|
||||
opening_name = None
|
||||
obj_name = None
|
||||
@@ -95,8 +36,12 @@ class PieAddOpening(bpy.types.Operator):
|
||||
class PieUpdateContainer(bpy.types.Operator):
|
||||
bl_idname = "bim.pie_update_container"
|
||||
bl_label = "Update Spatial Container"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
for obj in context.selected_objects:
|
||||
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||
continue
|
||||
@@ -127,10 +72,10 @@ class VIEW3D_MT_PIE_bim_class(bpy.types.Menu):
|
||||
|
||||
def draw(self, context):
|
||||
pie = self.layout.menu_pie()
|
||||
pie.operator("bim.assign_ifc_wall")
|
||||
pie.operator("bim.assign_ifc_slab")
|
||||
pie.operator("bim.assign_ifc_stair")
|
||||
pie.operator("bim.assign_ifc_door")
|
||||
pie.operator("bim.assign_ifc_window")
|
||||
pie.operator("bim.assign_ifc_column")
|
||||
pie.operator("bim.assign_ifc_beam")
|
||||
pie.operator("bim.assign_class", text="IfcWall").ifc_class = "IfcWall"
|
||||
pie.operator("bim.assign_class", text="IfcSlab").ifc_class = "IfcSlab"
|
||||
pie.operator("bim.assign_class", text="IfcStair").ifc_class = "IfcStair"
|
||||
pie.operator("bim.assign_class", text="IfcDoor").ifc_class = "IfcDoor"
|
||||
pie.operator("bim.assign_class", text="IfcWindow").ifc_class = "IfcWindow"
|
||||
pie.operator("bim.assign_class", text="IfcColumn").ifc_class = "IfcColumn"
|
||||
pie.operator("bim.assign_class", text="IfcBeam").ifc_class = "IfcBeam"
|
||||
|
||||
@@ -17,6 +17,9 @@ class AddTypeInstance(bpy.types.Operator):
|
||||
relating_type: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
tprops = context.scene.BIMTypeProperties
|
||||
ifc_class = self.ifc_class or tprops.ifc_class
|
||||
relating_type = self.relating_type or tprops.relating_type
|
||||
|
||||
@@ -43,6 +43,9 @@ class AddWall(bpy.types.Operator):
|
||||
join_type: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMModelProperties
|
||||
bpy.ops.bim.add_type_instance(ifc_class="IfcWallType", relating_type=int(props.relating_type))
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -172,12 +172,16 @@ def add_object(self, context):
|
||||
class BIM_OT_add_object(Operator):
|
||||
bl_idname = "mesh.add_window"
|
||||
bl_label = "Dumb Window"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
overall_width: FloatProperty(name="Overall Width", default=0.7)
|
||||
overall_height: FloatProperty(name="Overall Height", default=1)
|
||||
depth: FloatProperty(name="Depth", default=0.1)
|
||||
|
||||
def execute(self, context):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
add_object(self, context)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user