mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 14:07:43 +00:00
Assigning a layer set for the first time prefills with a layer to prevent invalid data.
This commit is contained in:
@@ -148,14 +148,27 @@ class AssignMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
material = tool.Ifc.get().by_id(int(active_obj.BIMObjectMaterialProperties.material))
|
material = tool.Ifc.get().by_id(int(active_obj.BIMObjectMaterialProperties.material))
|
||||||
for obj in objects:
|
for obj in objects:
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
if element:
|
if not element:
|
||||||
ifcopenshell.api.run(
|
continue
|
||||||
"material.assign_material",
|
ifcopenshell.api.run(
|
||||||
tool.Ifc.get(),
|
"material.assign_material",
|
||||||
product=element,
|
tool.Ifc.get(),
|
||||||
type=active_object_material_type,
|
product=element,
|
||||||
material=material,
|
type=active_object_material_type,
|
||||||
)
|
material=material,
|
||||||
|
)
|
||||||
|
assigned_material = ifcopenshell.util.element.get_material(element)
|
||||||
|
if assigned_material.is_a("IfcMaterialLayerSet"):
|
||||||
|
if not assigned_material.MaterialLayers:
|
||||||
|
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
|
layer = ifcopenshell.api.run(
|
||||||
|
"material.add_layer",
|
||||||
|
tool.Ifc.get(),
|
||||||
|
layer_set=assigned_material,
|
||||||
|
material=tool.Ifc.get().by_type("IfcMaterial")[0],
|
||||||
|
)
|
||||||
|
thickness = 0.1 # Arbitrary metric thickness for now
|
||||||
|
layer.LayerThickness = thickness / unit_scale
|
||||||
|
|
||||||
|
|
||||||
class UnassignMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
class UnassignMaterial(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
|
|||||||
Reference in New Issue
Block a user