mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix #5204. Bug where you could attempt to add IFC objects in edit mode which isn't allowed.
This commit is contained in:
@@ -494,6 +494,10 @@ class BIM_OT_add_door(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_label = "Door"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return tool.Ifc.get() and context.mode == "OBJECT"
|
||||
|
||||
def _execute(self, context):
|
||||
ifc_file = tool.Ifc.get()
|
||||
if not ifc_file:
|
||||
|
||||
@@ -82,7 +82,7 @@ class BIM_OT_add_object(Operator, tool.Ifc.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return tool.Ifc.get()
|
||||
return tool.Ifc.get() and context.mode == "OBJECT"
|
||||
|
||||
def _execute(self, context):
|
||||
add_object(self, context)
|
||||
|
||||
@@ -283,6 +283,10 @@ class BIM_OT_add_railing(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_label = "Railing"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return tool.Ifc.get() and context.mode == "OBJECT"
|
||||
|
||||
def _execute(self, context):
|
||||
ifc_file = tool.Ifc.get()
|
||||
if not ifc_file:
|
||||
|
||||
@@ -499,6 +499,10 @@ class BIM_OT_add_roof(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_label = "Roof"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return tool.Ifc.get() and context.mode == "OBJECT"
|
||||
|
||||
def _execute(self, context):
|
||||
ifc_file = tool.Ifc.get()
|
||||
if not ifc_file:
|
||||
|
||||
@@ -155,6 +155,10 @@ class BIM_OT_add_stair(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_label = "Stair"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return tool.Ifc.get() and context.mode == "OBJECT"
|
||||
|
||||
def _execute(self, context):
|
||||
ifc_file = tool.Ifc.get()
|
||||
if not ifc_file:
|
||||
|
||||
@@ -663,10 +663,11 @@ def add_menu(self, context):
|
||||
|
||||
|
||||
def add_mesh_object_menu(self, context):
|
||||
self.layout.separator()
|
||||
self.layout.operator("mesh.add_grid", icon_value=bonsai.bim.icons["IFC"].icon_id)
|
||||
self.layout.operator("mesh.add_stair", icon_value=bonsai.bim.icons["IFC"].icon_id)
|
||||
self.layout.operator("mesh.add_window", icon_value=bonsai.bim.icons["IFC"].icon_id)
|
||||
self.layout.operator("mesh.add_door", icon_value=bonsai.bim.icons["IFC"].icon_id)
|
||||
self.layout.operator("mesh.add_railing", icon_value=bonsai.bim.icons["IFC"].icon_id)
|
||||
self.layout.operator("mesh.add_roof", icon_value=bonsai.bim.icons["IFC"].icon_id)
|
||||
if context.mode == "OBJECT":
|
||||
self.layout.separator()
|
||||
self.layout.operator("mesh.add_grid", icon_value=bonsai.bim.icons["IFC"].icon_id)
|
||||
self.layout.operator("mesh.add_stair", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Stair (Untyped)")
|
||||
self.layout.operator("mesh.add_window", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Window (Untyped)")
|
||||
self.layout.operator("mesh.add_door", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Door (Untyped)")
|
||||
self.layout.operator("mesh.add_railing", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Railing (Untyped)")
|
||||
self.layout.operator("mesh.add_roof", icon_value=bonsai.bim.icons["IFC"].icon_id, text="Roof (Untyped)")
|
||||
|
||||
@@ -387,6 +387,10 @@ class BIM_OT_add_window(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_label = "Window"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return tool.Ifc.get() and context.mode == "OBJECT"
|
||||
|
||||
def _execute(self, context):
|
||||
ifc_file = tool.Ifc.get()
|
||||
if not ifc_file:
|
||||
|
||||
Reference in New Issue
Block a user