Add predefined type to AuthoringData

This commit is contained in:
Massimo Fabbro
2023-09-27 18:28:38 +02:00
parent d0ef7f69b1
commit 1621449143
4 changed files with 36 additions and 3 deletions
@@ -38,3 +38,4 @@ import ifcopenshell
class BIMCoveringProperties(PropertyGroup): class BIMCoveringProperties(PropertyGroup):
pass pass
# depth: bpy.props.FloatProperty(name="Depth", default=0.1, subtype="DISTANCE", description="Flooring depth") # depth: bpy.props.FloatProperty(name="Depth", default=0.1, subtype="DISTANCE", description="Flooring depth")
depth: bpy.props.FloatProperty(name="ceiling_height", default=2.7, subtype="DISTANCE", description="Ceiling height")
@@ -93,8 +93,32 @@ class CoveringToolUI:
row.label(text="", icon="EVENT_A") row.label(text="", icon="EVENT_A")
active_obj = bpy.context.active_object active_obj = bpy.context.active_object
element = tool.Ifc.get_entity(active_obj) element = tool.Ifc.get_entity(active_obj)
if element and bpy.context.selected_objects and element.is_a("IfcWall"):
op = row.operator("bim.add_instance_flooring_coverings_from_walls") if AuthoringData.data["predefined_type"] == "FLOORING":
if element and bpy.context.selected_objects and element.is_a("IfcWall"):
op = row.operator("bim.add_instance_flooring_coverings_from_walls")
# elif element and bpy.context.selected_objects and element.is_a("IfcSpace"):
# op. = row.operator("bim.add_istance_flooring_from_spaces"):
else:
# op = row.operator("bim.add_instance_flooring_from_cursor")
op = row.operator("bim.add_constr_type_instance", text="Add")
op.from_invoke = True
if cls.props.relating_type_id.isnumeric():
op.relating_type_id = int(cls.props.relating_type_id)
# elif AuthoringData.data["predefined_type"] == "CEILING":
# row = cls.layout.row(align=True)
# row.prop(data=cls.props, property="ceiling_height", text="ceiling height")
# if element and bpy.context.selected_objects and element.is_a("IfcWall"):
# op = row.operator("bim.add_instance_ceiling_coverings_from_walls")
# elif element and bpy.context.selected_objects and element.is_a("IfcSpace"):
# op. = row.operator("bim.add_istance_flooring_from_spaces"):
# else:
# op = row.operator("bim.add_instance_ceiling_from_cursor")
# op = row.operator("bim.add_constr_type_instance", text="Add")
# op.from_invoke = True
# if cls.props.relating_type_id.isnumeric():
# op.relating_type_id = int(cls.props.relating_type_id)
else: else:
op = row.operator("bim.add_constr_type_instance", text="Add") op = row.operator("bim.add_constr_type_instance", text="Add")
op.from_invoke = True op.from_invoke = True
@@ -25,7 +25,7 @@ import blenderbim.core.covering as core
class AddInstanceFlooringCoveringsFromWalls(bpy.types.Operator, tool.Ifc.Operator): class AddInstanceFlooringCoveringsFromWalls(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.add_instance_flooring_coverings_from_walls" bl_idname = "bim.add_instance_flooring_coverings_from_walls"
bl_label = "Add Typed Covering From Walls" bl_label = "Add Covering From Walls"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
bl_description = "Add instance flooring coverings from selected walls. The active object must be a wall and layered vertically" bl_description = "Add instance flooring coverings from selected walls. The active object must be a wall and layered vertically"
@@ -53,6 +53,7 @@ class AuthoringData:
cls.data["ifc_element_type"] = cls.ifc_element_type cls.data["ifc_element_type"] = cls.ifc_element_type
cls.data["ifc_classes"] = cls.ifc_classes() cls.data["ifc_classes"] = cls.ifc_classes()
cls.data["relating_type_id"] = cls.relating_type_id() # only after .ifc_classes() cls.data["relating_type_id"] = cls.relating_type_id() # only after .ifc_classes()
cls.data["predefined_type"] = cls.predefined_type()
cls.data["type_class"] = cls.type_class() cls.data["type_class"] = cls.type_class()
# only after .type_class() # only after .type_class()
@@ -247,6 +248,13 @@ class AuthoringData:
return [(str(e.id()), e.Name or "Unnamed", e.Description or "") for e in results] return [(str(e.id()), e.Name or "Unnamed", e.Description or "") for e in results]
return [] return []
@classmethod
def predefined_type(cls):
relating_type_id = cls.props.relating_type_id
relating_type = tool.Ifc.get().by_id(int(relating_type_id))
predefined_type = relating_type.PredefinedType
return predefined_type
@classmethod @classmethod
def selected_material_usages(cls): def selected_material_usages(cls):
selected_usages = {} selected_usages = {}