mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-13 06:53:36 +00:00
UI problem with creating empty material layer set causing issues #3169
Now it's also possible to select some material that will be used for they first layer of material layer set.
This commit is contained in:
@@ -189,17 +189,23 @@ class AssignMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
material=material,
|
material=material,
|
||||||
)
|
)
|
||||||
assigned_material = ifcopenshell.util.element.get_material(element)
|
assigned_material = ifcopenshell.util.element.get_material(element)
|
||||||
if assigned_material.is_a("IfcMaterialLayerSet"):
|
if assigned_material.is_a() in ("IfcMaterialLayerSet", "IfcMaterialLayerSetUsage"):
|
||||||
if not assigned_material.MaterialLayers:
|
if assigned_material.is_a("IfcMaterialLayerSet"):
|
||||||
|
layer_set = assigned_material
|
||||||
|
else:
|
||||||
|
layer_set = assigned_material.ForLayerSet
|
||||||
|
|
||||||
|
if not layer_set.MaterialLayers:
|
||||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
layer = ifcopenshell.api.run(
|
layer = ifcopenshell.api.run(
|
||||||
"material.add_layer",
|
"material.add_layer",
|
||||||
tool.Ifc.get(),
|
tool.Ifc.get(),
|
||||||
layer_set=assigned_material,
|
layer_set=layer_set,
|
||||||
material=tool.Ifc.get().by_type("IfcMaterial")[0],
|
material=material,
|
||||||
)
|
)
|
||||||
thickness = 0.1 # Arbitrary metric thickness for now
|
thickness = 0.1 # Arbitrary metric thickness for now
|
||||||
layer.LayerThickness = thickness / unit_scale
|
layer.LayerThickness = thickness / unit_scale
|
||||||
|
|
||||||
elif assigned_material.is_a("IfcMaterialProfileSet"):
|
elif assigned_material.is_a("IfcMaterialProfileSet"):
|
||||||
if not assigned_material.MaterialProfiles:
|
if not assigned_material.MaterialProfiles:
|
||||||
named_profiles = [p for p in tool.Ifc.get().by_type("IfcProfileDef") if p.ProfileName]
|
named_profiles = [p for p in tool.Ifc.get().by_type("IfcProfileDef") if p.ProfileName]
|
||||||
@@ -368,7 +374,9 @@ class RemoveLayer(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
for inverse in tool.Ifc.get().get_inverse(tool.Ifc.get().by_id(self.layer)):
|
for inverse in tool.Ifc.get().get_inverse(tool.Ifc.get().by_id(self.layer)):
|
||||||
if inverse.is_a("IfcMaterialLayerSet") and len(inverse.MaterialLayers) == 1:
|
if inverse.is_a("IfcMaterialLayerSet") and len(inverse.MaterialLayers) == 1:
|
||||||
self.report({"ERROR"}, "Cannot remove material layer - IfcMaterialLayerSet should alawys have atleast 1 layer")
|
self.report(
|
||||||
|
{"ERROR"}, "Cannot remove material layer - IfcMaterialLayerSet should alawys have atleast 1 layer"
|
||||||
|
)
|
||||||
return {"ERROR"}
|
return {"ERROR"}
|
||||||
ifcopenshell.api.run("material.remove_layer", tool.Ifc.get(), layer=tool.Ifc.get().by_id(self.layer))
|
ifcopenshell.api.run("material.remove_layer", tool.Ifc.get(), layer=tool.Ifc.get().by_id(self.layer))
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,12 @@ class BIM_PT_object_material(Panel):
|
|||||||
|
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
prop_with_search(row, self.props, "material_type", text="")
|
prop_with_search(row, self.props, "material_type", text="")
|
||||||
if self.props.material_type == "IfcMaterial" or self.props.material_type == "IfcMaterialList":
|
if self.props.material_type in (
|
||||||
|
"IfcMaterial",
|
||||||
|
"IfcMaterialList",
|
||||||
|
"IfcMaterialLayerSet",
|
||||||
|
"IfcMaterialLayerSetUsage",
|
||||||
|
):
|
||||||
prop_with_search(row, self.props, "material", text="")
|
prop_with_search(row, self.props, "material", text="")
|
||||||
row.operator("bim.assign_material", icon="ADD", text="")
|
row.operator("bim.assign_material", icon="ADD", text="")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user