Skip to content

Commit

Permalink
Fix bug where unnamed profiles clogged up the material profile settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Moult committed Feb 4, 2023
1 parent a7cc58f commit 42c4a68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/blenderbim/blenderbim/bim/module/material/data.py
Expand Up @@ -73,7 +73,11 @@ def material_types(cls):

@classmethod
def profiles(cls):
return [(str(p.id()), p.ProfileName or "Unnamed", "") for p in tool.Ifc.get().by_type("IfcProfileDef")]
return [
(str(p.id()), p.ProfileName or "Unnamed", "")
for p in tool.Ifc.get().by_type("IfcProfileDef")
if p.ProfileName
]


class ObjectMaterialData:
Expand Down
17 changes: 9 additions & 8 deletions src/blenderbim/blenderbim/bim/module/type/operator.py
Expand Up @@ -253,8 +253,14 @@ def _execute(self, context):
material = materials[0] # Arbitrarily pick a material
else:
material = self.add_default_material()
size = 0.5 / unit_scale
profile = ifc_file.create_entity("IfcRectangleProfileDef", ProfileType="AREA", XDim=size, YDim=size)
named_profiles = [p for p in ifc_file.by_type("IfcProfileDef") if p.ProfileName]
if named_profiles:
profile = named_profiles[0]
else:
size = 0.5 / unit_scale
profile = ifc_file.create_entity(
"IfcRectangleProfileDef", ProfileName="New Profile", ProfileType="AREA", XDim=size, YDim=size
)
rel = ifcopenshell.api.run(
"material.assign_material", ifc_file, product=element, type="IfcMaterialProfileSet"
)
Expand Down Expand Up @@ -282,12 +288,7 @@ def _execute(self, context):
mesh = bpy.data.meshes.new("IfcWindow")
obj = bpy.data.objects.new("TYPEX", mesh)
element = blenderbim.core.root.assign_class(
tool.Ifc,
tool.Collector,
tool.Root,
obj=obj,
ifc_class="IfcWindowType",
should_add_representation=False
tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcWindowType", should_add_representation=False
)
bpy.ops.object.select_all(action="DESELECT")
bpy.context.view_layer.objects.active = None
Expand Down

0 comments on commit 42c4a68

Please sign in to comment.