You can now specify custom names for types instead of relying on the default "TYPEX" naming

This commit is contained in:
Sigma Dimensions
2023-03-11 14:13:32 +01:00
parent fad5c7c921
commit 8624888bfc
3 changed files with 12 additions and 9 deletions
@@ -244,6 +244,7 @@ class BIMModelProperties(PropertyGroup):
) )
type_class: bpy.props.EnumProperty(items=get_type_class, name="IFC Class", update=update_type_class) type_class: bpy.props.EnumProperty(items=get_type_class, name="IFC Class", update=update_type_class)
type_predefined_type: bpy.props.EnumProperty(items=get_type_predefined_type, name="Predefined Type", default=None) type_predefined_type: bpy.props.EnumProperty(items=get_type_predefined_type, name="Predefined Type", default=None)
type_name: bpy.props.StringProperty(name="Name", default="TYPEX")
class BIMArrayProperties(PropertyGroup): class BIMArrayProperties(PropertyGroup):
@@ -72,6 +72,7 @@ class LaunchTypeManager(bpy.types.Operator):
row.alignment = "CENTER" row.alignment = "CENTER"
row.prop(props, "type_predefined_type", text="") row.prop(props, "type_predefined_type", text="")
row.prop(props, "type_template", text="") row.prop(props, "type_template", text="")
row.prop(props, "type_name", text="")
row.operator("bim.add_type", icon="ADD", text="") row.operator("bim.add_type", icon="ADD", text="")
row = columns.row(align=True) row = columns.row(align=True)
@@ -162,6 +162,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
props = context.scene.BIMModelProperties props = context.scene.BIMModelProperties
ifc_class = props.type_class ifc_class = props.type_class
predefined_type = props.type_predefined_type predefined_type = props.type_predefined_type
name = props.type_name
template = props.type_template template = props.type_template
ifc_file = tool.Ifc.get() ifc_file = tool.Ifc.get()
body = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW") body = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
@@ -176,14 +177,14 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
if element: if element:
mesh = obj.data.copy() mesh = obj.data.copy()
mesh.BIMMeshProperties.ifc_definition_id = 0 mesh.BIMMeshProperties.ifc_definition_id = 0
obj = bpy.data.objects.new(element.Name or "TYPEX", mesh) obj = bpy.data.objects.new(element.Name or name, mesh)
else: else:
mesh = bpy.data.meshes.new("TYPEX") mesh = bpy.data.meshes.new(name)
bm = bmesh.new() bm = bmesh.new()
bmesh.ops.create_cube(bm, size=1) bmesh.ops.create_cube(bm, size=1)
bm.to_mesh(mesh) bm.to_mesh(mesh)
bm.free() bm.free()
obj = bpy.data.objects.new("TYPEX", mesh) obj = bpy.data.objects.new(name, mesh)
obj.matrix_world.col[3] = location.to_4d() obj.matrix_world.col[3] = location.to_4d()
blenderbim.core.root.assign_class( blenderbim.core.root.assign_class(
tool.Ifc, tool.Ifc,
@@ -198,7 +199,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
) )
elif template in ("LAYERSET_AXIS2", "LAYERSET_AXIS3"): elif template in ("LAYERSET_AXIS2", "LAYERSET_AXIS3"):
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file) unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
obj = bpy.data.objects.new("TYPEX", None) obj = bpy.data.objects.new(name, None)
element = blenderbim.core.root.assign_class( element = blenderbim.core.root.assign_class(
tool.Ifc, tool.Ifc,
tool.Collector, tool.Collector,
@@ -231,7 +232,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
ifcopenshell.api.run("pset.edit_pset", ifc_file, pset=pset, properties={"LayerSetDirection": axis}) ifcopenshell.api.run("pset.edit_pset", ifc_file, pset=pset, properties={"LayerSetDirection": axis})
elif template == "PROFILESET": elif template == "PROFILESET":
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file) unit_scale = ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
obj = bpy.data.objects.new("TYPEX", None) obj = bpy.data.objects.new(name, None)
element = blenderbim.core.root.assign_class( element = blenderbim.core.root.assign_class(
tool.Ifc, tool.Ifc,
tool.Collector, tool.Collector,
@@ -267,7 +268,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
"material.assign_profile", ifc_file, material_profile=material_profile, profile=profile "material.assign_profile", ifc_file, material_profile=material_profile, profile=profile
) )
elif template == "EMPTY": elif template == "EMPTY":
obj = bpy.data.objects.new("TYPEX", None) obj = bpy.data.objects.new(name, None)
blenderbim.core.root.assign_class( blenderbim.core.root.assign_class(
tool.Ifc, tool.Ifc,
tool.Collector, tool.Collector,
@@ -282,7 +283,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
elif template == "WINDOW": elif template == "WINDOW":
mesh = bpy.data.meshes.new("IfcWindow") mesh = bpy.data.meshes.new("IfcWindow")
obj = bpy.data.objects.new("TYPEX", mesh) obj = bpy.data.objects.new(name, mesh)
element = blenderbim.core.root.assign_class( element = blenderbim.core.root.assign_class(
tool.Ifc, tool.Ifc,
tool.Collector, tool.Collector,
@@ -300,7 +301,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
elif template == "DOOR": elif template == "DOOR":
mesh = bpy.data.meshes.new("IfcDoor") mesh = bpy.data.meshes.new("IfcDoor")
obj = bpy.data.objects.new("TYPEX", mesh) obj = bpy.data.objects.new(name, mesh)
element = blenderbim.core.root.assign_class( element = blenderbim.core.root.assign_class(
tool.Ifc, tool.Ifc,
tool.Collector, tool.Collector,
@@ -318,7 +319,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
elif template == "STAIR": elif template == "STAIR":
mesh = bpy.data.meshes.new("IfcStairFlight") mesh = bpy.data.meshes.new("IfcStairFlight")
obj = bpy.data.objects.new("TYPEX", mesh) obj = bpy.data.objects.new(name, mesh)
element = blenderbim.core.root.assign_class( element = blenderbim.core.root.assign_class(
tool.Ifc, tool.Ifc,
tool.Collector, tool.Collector,