You can now add layerset types in the type manager and access the manager on blank projects.

This commit is contained in:
Dion Moult
2022-10-23 20:02:34 +11:00
parent 89e8bf1ed6
commit 6263110733
3 changed files with 45 additions and 8 deletions
@@ -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)
@@ -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="")
@@ -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(