From 6263110733778c0f6b33da6b7dff882e4fae3594 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 23 Oct 2022 20:02:34 +1100 Subject: [PATCH] You can now add layerset types in the type manager and access the manager on blank projects. --- .../blenderbim/bim/module/model/ui.py | 2 +- .../blenderbim/bim/module/model/workspace.py | 15 ++++---- .../blenderbim/bim/module/type/operator.py | 36 +++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/model/ui.py b/src/blenderbim/blenderbim/bim/module/model/ui.py index 5fa58556f5..25a18eeb49 100644 --- a/src/blenderbim/blenderbim/bim/module/model/ui.py +++ b/src/blenderbim/blenderbim/bim/module/model/ui.py @@ -37,7 +37,7 @@ class LaunchTypeManager(bpy.types.Operator): props.type_page = 1 if props.ifc_class: props.type_class = props.ifc_class - bpy.ops.bim.load_type_thumbnails(ifc_class=props.ifc_class) + bpy.ops.bim.load_type_thumbnails(ifc_class=props.ifc_class) if not AuthoringData.is_loaded: AuthoringData.load() return context.window_manager.invoke_popup(self, width=550) diff --git a/src/blenderbim/blenderbim/bim/module/model/workspace.py b/src/blenderbim/blenderbim/bim/module/model/workspace.py index 86c8c8214d..96d3dfc2d8 100644 --- a/src/blenderbim/blenderbim/bim/module/model/workspace.py +++ b/src/blenderbim/blenderbim/bim/module/model/workspace.py @@ -300,15 +300,16 @@ class BimToolUI: if AuthoringData.data["ifc_classes"]: row.label(text="", icon="FILE_VOLUME") row.prop(data=cls.props, property="ifc_class", text="") - else: - row.label(text="No Construction Class", icon="FILE_VOLUME") - row = cls.layout.row(align=True) - if AuthoringData.data["relating_types_ids"]: - row.label(text="", icon="FILE_3D") - prop_with_search(row, cls.props, "relating_type_id", text="") + row = cls.layout.row(align=True) + if AuthoringData.data["relating_types_ids"]: + row.label(text="", icon="FILE_3D") + prop_with_search(row, cls.props, "relating_type_id", text="") + else: + row.label(text="No Construction Type", icon="FILE_3D") row.operator("bim.launch_type_manager", icon="LIGHTPROBE_GRID", text="") else: - row.label(text="No Construction Type", icon="FILE_3D") + row.operator("bim.launch_type_manager", icon="LIGHTPROBE_GRID") + if AuthoringData.data["ifc_classes"]: #row = cls.layout.row() #row.operator("bim.display_constr_types", icon="TRIA_DOWN", text="") diff --git a/src/blenderbim/blenderbim/bim/module/type/operator.py b/src/blenderbim/blenderbim/bim/module/type/operator.py index 470271d57d..155d3d958c 100644 --- a/src/blenderbim/blenderbim/bim/module/type/operator.py +++ b/src/blenderbim/blenderbim/bim/module/type/operator.py @@ -208,6 +208,42 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator): context=body, ifc_representation_class=None, ) + elif template in ("LAYERSET_AXIS2", "LAYERSET_AXIS3"): + unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) + obj = bpy.data.objects.new("TYPEX", None) + element = blenderbim.core.root.assign_class( + tool.Ifc, + tool.Collector, + tool.Root, + obj=obj, + ifc_class=ifc_class, + predefined_type=predefined_type, + should_add_representation=True, + context=body, + ifc_representation_class=None, + ) + materials = tool.Ifc.get().by_type("IfcMaterial") + if materials: + material = materials[0] # Arbitrarily pick a material + else: + material = ifcopenshell.api.run("material.add_material", tool.Ifc.get(), name="Unknown") + blender_material = bpy.data.materials.new(material.Name) + tool.Ifc.link(material, blender_material) + blender_material.use_fake_user = True + rel = ifcopenshell.api.run( + "material.assign_material", tool.Ifc.get(), product=element, type="IfcMaterialLayerSet" + ) + layer_set = rel.RelatingMaterial + layer = ifcopenshell.api.run("material.add_layer", tool.Ifc.get(), layer_set=layer_set, material=material) + thickness = 0.1 # Arbitrary metric thickness for now + layer.LayerThickness = thickness / unit_scale + + pset = ifcopenshell.api.run("pset.add_pset", tool.Ifc.get(), product=element, name="EPset_Parametric") + if template == "LAYERSET_AXIS2": + axis = "AXIS2" + elif template == "LAYERSET_AXIS3": + axis = "AXIS3" + ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties={"LayerSetDirection": axis}) elif template == "EMPTY": obj = bpy.data.objects.new("TYPEX", None) blenderbim.core.root.assign_class(