mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 19:12:31 +00:00
Fix bug where unnamed profiles clogged up the material profile settings.
This commit is contained in:
@@ -73,7 +73,11 @@ class MaterialsData:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def profiles(cls):
|
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:
|
class ObjectMaterialData:
|
||||||
|
|||||||
@@ -253,8 +253,14 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
material = materials[0] # Arbitrarily pick a material
|
material = materials[0] # Arbitrarily pick a material
|
||||||
else:
|
else:
|
||||||
material = self.add_default_material()
|
material = self.add_default_material()
|
||||||
size = 0.5 / unit_scale
|
named_profiles = [p for p in ifc_file.by_type("IfcProfileDef") if p.ProfileName]
|
||||||
profile = ifc_file.create_entity("IfcRectangleProfileDef", ProfileType="AREA", XDim=size, YDim=size)
|
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(
|
rel = ifcopenshell.api.run(
|
||||||
"material.assign_material", ifc_file, product=element, type="IfcMaterialProfileSet"
|
"material.assign_material", ifc_file, product=element, type="IfcMaterialProfileSet"
|
||||||
)
|
)
|
||||||
@@ -282,12 +288,7 @@ class AddType(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
mesh = bpy.data.meshes.new("IfcWindow")
|
mesh = bpy.data.meshes.new("IfcWindow")
|
||||||
obj = bpy.data.objects.new("TYPEX", mesh)
|
obj = bpy.data.objects.new("TYPEX", mesh)
|
||||||
element = blenderbim.core.root.assign_class(
|
element = blenderbim.core.root.assign_class(
|
||||||
tool.Ifc,
|
tool.Ifc, tool.Collector, tool.Root, obj=obj, ifc_class="IfcWindowType", should_add_representation=False
|
||||||
tool.Collector,
|
|
||||||
tool.Root,
|
|
||||||
obj=obj,
|
|
||||||
ifc_class="IfcWindowType",
|
|
||||||
should_add_representation=False
|
|
||||||
)
|
)
|
||||||
bpy.ops.object.select_all(action="DESELECT")
|
bpy.ops.object.select_all(action="DESELECT")
|
||||||
bpy.context.view_layer.objects.active = None
|
bpy.context.view_layer.objects.active = None
|
||||||
|
|||||||
Reference in New Issue
Block a user