Small type manager refactor and more descriptions

This commit is contained in:
Andrej730
2023-07-20 10:47:47 +05:00
parent 1b71f4f569
commit 6b276b8aed
2 changed files with 23 additions and 35 deletions
@@ -137,16 +137,17 @@ class BIMModelProperties(PropertyGroup):
type_page: bpy.props.IntProperty(name="Type Page", default=1, update=update_type_page)
type_template: bpy.props.EnumProperty(
items=(
("MESH", "Custom Mesh", ""),
("LAYERSET_AXIS2", "Vertical Layers", "For objects similar to walls"),
("LAYERSET_AXIS3", "Horizontal Layers", "For objects similar to slabs"),
("PROFILESET", "Extruded Profile", ""),
("EMPTY", "Non-Geometric Type", ""),
("WINDOW", "Window", ""),
("DOOR", "Door", ""),
("STAIR", "Stair", ""),
("RAILING", "Railing", ""),
("ROOF", "Roof", ""),
("MESH", "Custom Mesh", "Use as a representation currently active object mesh or default cube if no object selected"),
("LAYERSET_AXIS2", "Vertical Layers", "For objects similar to walls, will automatically add IfcMaterialLayerSet"),
("LAYERSET_AXIS3", "Horizontal Layers", "For objects similar to slabs, will automatically add IfcMaterialLayerSet"),
("PROFILESET", "Extruded Profile", "Create profile type object, automatically defines IfcMaterialProfileSet with the first profile from library"),
("EMPTY", "Non-Geometric Type", "Start with an empty object"),
("WINDOW", "Window", "Parametric window"),
("DOOR", "Door", "Parametric door"),
("STAIR", "Stair", "Parametric stair"),
("RAILING", "Railing", "Parametric railing"),
("ROOF", "Roof", "Parametric roof"),
),
name="Type Template",
default="MESH",
@@ -212,6 +212,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
body = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
if not body:
props.type_class = props.type_class
self.report({"ERROR"}, "No Model/Body/MODEL_VIEW context found.")
return {"FINISHED"}
if template == "MESH":
@@ -314,6 +315,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
ifcopenshell.api.run(
"material.assign_profile", ifc_file, material_profile=material_profile, profile=profile
)
elif template == "EMPTY":
obj = bpy.data.objects.new(name, None)
blenderbim.core.root.assign_class(
@@ -329,7 +331,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
)
elif template == "WINDOW":
mesh = bpy.data.meshes.new("IfcWindow")
mesh = bpy.data.meshes.new(name)
obj = bpy.data.objects.new(name, mesh)
element = blenderbim.core.root.assign_class(
tool.Ifc,
@@ -340,14 +342,11 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
ifc_class="IfcWindowType" if tool.Ifc.get_schema() != "IFC2X3" else "IfcWindowStyle",
should_add_representation=False,
)
bpy.ops.object.select_all(action="DESELECT")
bpy.context.view_layer.objects.active = None
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
tool.Blender.select_and_activate_single_object(context, obj)
bpy.ops.bim.add_window()
elif template == "DOOR":
mesh = bpy.data.meshes.new("IfcDoor")
mesh = bpy.data.meshes.new(name)
obj = bpy.data.objects.new(name, mesh)
element = blenderbim.core.root.assign_class(
tool.Ifc,
@@ -358,14 +357,11 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
ifc_class="IfcDoorType" if tool.Ifc.get_schema() != "IFC2X3" else "IfcDoorStyle",
should_add_representation=False,
)
bpy.ops.object.select_all(action="DESELECT")
bpy.context.view_layer.objects.active = None
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
tool.Blender.select_and_activate_single_object(context, obj)
bpy.ops.bim.add_door()
elif template == "STAIR":
mesh = bpy.data.meshes.new("IfcStairFlight")
mesh = bpy.data.meshes.new(name)
obj = bpy.data.objects.new(name, mesh)
element = blenderbim.core.root.assign_class(
tool.Ifc,
@@ -377,14 +373,11 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
should_add_representation=True,
context=body,
)
bpy.ops.object.select_all(action="DESELECT")
bpy.context.view_layer.objects.active = None
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
tool.Blender.select_and_activate_single_object(context, obj)
bpy.ops.bim.add_stair()
elif template == "RAILING":
mesh = bpy.data.meshes.new("IfcRailing")
mesh = bpy.data.meshes.new(name)
obj = bpy.data.objects.new(name, mesh)
element = blenderbim.core.root.assign_class(
tool.Ifc,
@@ -396,14 +389,11 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
should_add_representation=True,
context=body,
)
bpy.ops.object.select_all(action="DESELECT")
bpy.context.view_layer.objects.active = None
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
tool.Blender.select_and_activate_single_object(context, obj)
bpy.ops.bim.add_railing()
elif template == "ROOF":
mesh = bpy.data.meshes.new("IfcRoof")
mesh = bpy.data.meshes.new(name)
obj = bpy.data.objects.new(name, mesh)
element = blenderbim.core.root.assign_class(
tool.Ifc,
@@ -415,10 +405,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
should_add_representation=True,
context=body,
)
bpy.ops.object.select_all(action="DESELECT")
bpy.context.view_layer.objects.active = None
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
tool.Blender.select_and_activate_single_object(obj)
bpy.ops.bim.add_roof()
bpy.ops.bim.load_type_thumbnails(ifc_class=ifc_class)