diff --git a/src/blenderbim/blenderbim/bim/module/model/door.py b/src/blenderbim/blenderbim/bim/module/model/door.py index 6150f472c6..b488db5a62 100644 --- a/src/blenderbim/blenderbim/bim/module/model/door.py +++ b/src/blenderbim/blenderbim/bim/module/model/door.py @@ -513,10 +513,6 @@ class AddDoor(bpy.types.Operator, tool.Ifc.Operator): element = tool.Ifc.get_entity(obj) props = obj.BIMDoorProperties - if element.is_a() not in ("IfcDoor", "IfcDoorType", "IfcDoorStyle"): - self.report({"ERROR"}, "Object has to be IfcDoor/IfcDoorType/IfcDoorStyle type to add a door.") - return {"CANCELLED"} - door_data = props.get_general_kwargs(convert_to_project_units=True) lining_props = props.get_lining_kwargs(convert_to_project_units=True) panel_props = props.get_panel_kwargs(convert_to_project_units=True) diff --git a/src/blenderbim/blenderbim/bim/module/model/railing.py b/src/blenderbim/blenderbim/bim/module/model/railing.py index 245a963f61..f70c1c57e0 100644 --- a/src/blenderbim/blenderbim/bim/module/model/railing.py +++ b/src/blenderbim/blenderbim/bim/module/model/railing.py @@ -316,10 +316,6 @@ class AddRailing(bpy.types.Operator, tool.Ifc.Operator): props = obj.BIMRailingProperties si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) - if element.is_a() not in ("IfcRailing", "IfcRailingType"): - self.report({"ERROR"}, "Object has to be IfcRailing/IfcRailingType type to add a railing.") - return {"CANCELLED"} - railing_data = props.get_general_kwargs(convert_to_project_units=True) path_data = get_path_data(obj) if not path_data: diff --git a/src/blenderbim/blenderbim/bim/module/model/roof.py b/src/blenderbim/blenderbim/bim/module/model/roof.py index 13d4b402c6..06a1b67069 100644 --- a/src/blenderbim/blenderbim/bim/module/model/roof.py +++ b/src/blenderbim/blenderbim/bim/module/model/roof.py @@ -548,10 +548,6 @@ class AddRoof(bpy.types.Operator, tool.Ifc.Operator): props = obj.BIMRoofProperties si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) - if element.is_a() not in ("IfcRoof", "IfcRoofType"): - self.report({"ERROR"}, "Object has to be IfcRoof/IfcRoofType type to add a roof.") - return {"CANCELLED"} - # rejecting original roof shape to be safe # taking into account only it's bounding box dimensions if obj.dimensions.x == 0 or obj.dimensions.y == 0: diff --git a/src/blenderbim/blenderbim/bim/module/model/stair.py b/src/blenderbim/blenderbim/bim/module/model/stair.py index dbf24d3ae7..a444f510fc 100644 --- a/src/blenderbim/blenderbim/bim/module/model/stair.py +++ b/src/blenderbim/blenderbim/bim/module/model/stair.py @@ -361,10 +361,6 @@ class AddStair(bpy.types.Operator, tool.Ifc.Operator): props = obj.BIMStairProperties ifc_file = tool.Ifc.get() - if element.is_a() not in ("IfcStairFlight", "IfcStairFlightType"): - self.report({"ERROR"}, "Object has to be IfcStairFlight/IfcStairFlightType to add a stair.") - return {"CANCELLED"} - stair_data = props.get_props_kwargs(convert_to_project_units=True) pset = tool.Pset.get_element_pset(element, "BBIM_Stair") if not pset: diff --git a/src/blenderbim/blenderbim/bim/module/model/ui.py b/src/blenderbim/blenderbim/bim/module/model/ui.py index 75837229cb..b898af9b42 100644 --- a/src/blenderbim/blenderbim/bim/module/model/ui.py +++ b/src/blenderbim/blenderbim/bim/module/model/ui.py @@ -247,8 +247,7 @@ class BIM_PT_stair(bpy.types.Panel): @classmethod def poll(cls, context): - # always display modifier if it's IFC object - return tool.Ifc.get() and tool.Ifc.get_entity(context.active_object) + return tool.Blender.Modifier.is_eligible_for_stair_modifier(context.active_object) def draw(self, context): if not StairData.is_loaded: @@ -345,8 +344,7 @@ class BIM_PT_window(bpy.types.Panel): @classmethod def poll(cls, context): - # always display modifier if it's IFC object - return tool.Ifc.get() and tool.Ifc.get_entity(context.active_object) + return tool.Blender.Modifier.is_eligible_for_window_modifier(context.active_object) def draw(self, context): if not WindowData.is_loaded: @@ -455,8 +453,7 @@ class BIM_PT_door(bpy.types.Panel): @classmethod def poll(cls, context): - # always display modifier if it's IFC object - return tool.Ifc.get() and tool.Ifc.get_entity(context.active_object) + return tool.Blender.Modifier.is_eligible_for_door_modifier(context.active_object) def draw(self, context): if not DoorData.is_loaded: @@ -529,8 +526,7 @@ class BIM_PT_railing(bpy.types.Panel): @classmethod def poll(cls, context): - # always display modifier if it's IFC object - return tool.Ifc.get() and tool.Ifc.get_entity(context.active_object) + return tool.Blender.Modifier.is_eligible_for_railing_modifier(context.active_object) def draw(self, context): if not RailingData.is_loaded: @@ -592,8 +588,7 @@ class BIM_PT_roof(bpy.types.Panel): @classmethod def poll(cls, context): - # always display modifier if it's IFC object - return tool.Ifc.get() and tool.Ifc.get_entity(context.active_object) + return tool.Blender.Modifier.is_eligible_for_roof_modifier(context.active_object) def draw(self, context): if not RoofData.is_loaded: diff --git a/src/blenderbim/blenderbim/bim/module/model/window.py b/src/blenderbim/blenderbim/bim/module/model/window.py index ea5458da4d..edd989fcaa 100644 --- a/src/blenderbim/blenderbim/bim/module/model/window.py +++ b/src/blenderbim/blenderbim/bim/module/model/window.py @@ -482,10 +482,6 @@ class AddWindow(bpy.types.Operator, tool.Ifc.Operator): element = tool.Ifc.get_entity(obj) props = obj.BIMWindowProperties - if element.is_a() not in ("IfcWindow", "IfcWindowType", "IfcWindowStyle"): - self.report({"ERROR"}, "Object has to be IfcWindow/IfcWindowType/IfcWindowStyle type to add a window.") - return {"CANCELLED"} - window_data = props.get_general_kwargs(convert_to_project_units=True) lining_props = props.get_lining_kwargs(convert_to_project_units=True) panel_props = props.get_panel_kwargs(convert_to_project_units=True) diff --git a/src/blenderbim/blenderbim/tool/blender.py b/src/blenderbim/blenderbim/tool/blender.py index c6f08fe548..49cc54d878 100644 --- a/src/blenderbim/blenderbim/tool/blender.py +++ b/src/blenderbim/blenderbim/tool/blender.py @@ -458,6 +458,33 @@ class Blender: return {"CANCELLED"} class Modifier: + @classmethod + def is_object_an_ifc_class(cls, obj, classes): + if not tool.Ifc.get(): + return False + element = tool.Ifc.get_entity(obj) + return element and element.is_a() in classes + + @classmethod + def is_eligible_for_railing_modifier(cls, obj): + return cls.is_object_an_ifc_class(obj, ("IfcRailing", "IfcRailingType")) + + @classmethod + def is_eligible_for_stair_modifier(cls, obj): + return cls.is_object_an_ifc_class(obj, ("IfcStairFlight", "IfcStairFlightType")) + + @classmethod + def is_eligible_for_window_modifier(cls, obj): + return cls.is_object_an_ifc_class(obj, ("IfcWindow", "IfcWindowType", "IfcWindowStyle")) + + @classmethod + def is_eligible_for_door_modifier(cls, obj): + return cls.is_object_an_ifc_class(obj, ("IfcDoor", "IfcDoorType", "IfcDoorStyle")) + + @classmethod + def is_eligible_for_roof_modifier(cls, obj): + return cls.is_object_an_ifc_class(obj, ("IfcRoof", "IfcRoofType")) + @classmethod def is_railing(cls, element): return tool.Pset.get_element_pset(element, "BBIM_Railing")