mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Show ifc modifiers only when applicable to current element
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user