BBIM: fix material errors, and add smoke tests

This commit is contained in:
Sigma Dimensions
2023-02-20 17:49:54 +01:00
parent 378a25bbaa
commit 40560b71c2
2 changed files with 46 additions and 5 deletions
@@ -242,7 +242,7 @@ class RemoveConstituent(bpy.types.Operator, tool.Ifc.Operator):
constituent: bpy.props.IntProperty()
def _execute(self, context):
for inverse in tool.Ifc.get().get_inverse(layer):
for inverse in tool.Ifc.get().get_inverse(tool.Ifc.get().by_id(self.constituent)):
if inverse.is_a("IfcMaterialConstituentSet") and len(inverse.MaterialConstituents) == 1:
return
ifcopenshell.api.run(
@@ -277,7 +277,7 @@ class RemoveProfile(bpy.types.Operator, tool.Ifc.Operator):
profile: bpy.props.IntProperty()
def _execute(self, context):
for inverse in tool.Ifc.get().get_inverse(layer):
for inverse in tool.Ifc.get().get_inverse(tool.Ifc.get().by_id(self.profile)):
if inverse.is_a("IfcMaterialProfileSet") and len(inverse.MaterialProfiles) == 1:
return
ifcopenshell.api.run("material.remove_profile", tool.Ifc.get(), profile=tool.Ifc.get().by_id(self.profile))
@@ -335,7 +335,7 @@ class RemoveLayer(bpy.types.Operator, tool.Ifc.Operator):
layer: bpy.props.IntProperty()
def _execute(self, context):
for inverse in tool.Ifc.get().get_inverse(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:
return
ifcopenshell.api.run("material.remove_layer", tool.Ifc.get(), layer=tool.Ifc.get().by_id(self.layer))
@@ -396,7 +396,7 @@ Scenario: Contract material category
When I press "bim.contract_material_category(category='')"
Then nothing happens
Scenario: Enable Editing Material set Item
Scenario: Enable editing material set item
Given an empty IFC project
And I load the demo construction library
When I set "scene.BIMModelProperties.ifc_class" to "IfcColumnType"
@@ -407,4 +407,45 @@ Scenario: Enable Editing Material set Item
And the variable "relating_material" is "{ifc}.by_id({column_type}).HasAssociations[0].RelatingMaterial.id()"
And the variable "material_profile" is "{ifc}.by_id({column_type}).HasAssociations[0].RelatingMaterial.MaterialProfiles[0].id()"
And I press "bim.enable_editing_assigned_material"
And I press "bim.enable_editing_material_set_item(material_set_item={material_profile})"
When I press "bim.enable_editing_material_set_item(material_set_item={material_profile})"
Then nothing happens
Scenario: Add material set layer
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And I add an empty
And the object "Empty" is selected
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
And I press "bim.assign_class"
And I press "bim.add_material(obj='')"
And I set "active_object.BIMObjectMaterialProperties.material_type" to "IfcMaterialLayerSet"
And I press "bim.assign_material"
And I press "bim.enable_editing_assigned_material"
And the variable "material_set" is "{ifc}.by_type('IfcMaterialLayerSet')[0].id()"
When I press "bim.add_layer(layer_set={material_set})"
Then nothing happens
Scenario: Remove material set layer
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And I add an empty
And the object "Empty" is selected
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
And I press "bim.assign_class"
And I press "bim.add_material(obj='')"
And I set "active_object.BIMObjectMaterialProperties.material_type" to "IfcMaterialLayerSet"
And I press "bim.assign_material"
And I press "bim.enable_editing_assigned_material"
And the variable "material_set" is "{ifc}.by_type('IfcMaterialLayerSet')[0].id()"
And I press "bim.remove_layer(layer={ifc}.by_id({material_set}).MaterialLayers[0].id())"
And I press "bim.add_layer(layer_set={material_set})"
When I press "bim.remove_layer(layer={ifc}.by_id({material_set}).MaterialLayers[0].id())"
Then nothing happens