mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-20 12:12:15 +00:00
#2094. New rudimentary project materials browser to manage materials.
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
@material
|
||||
Feature: Material
|
||||
|
||||
Scenario: Load materials
|
||||
Given an empty IFC project
|
||||
And I press "bim.add_default_material"
|
||||
When I press "bim.load_materials"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Disable editing materials
|
||||
Given an empty IFC project
|
||||
And I press "bim.add_default_material"
|
||||
And I press "bim.load_materials"
|
||||
When I press "bim.disable_editing_materials"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Add default material
|
||||
Given an empty IFC project
|
||||
When I press "bim.add_default_material"
|
||||
|
||||
@@ -141,7 +141,8 @@ class TestDisableEditingDrawings:
|
||||
|
||||
class TestAddDrawing:
|
||||
def test_run(self, ifc, collector, drawing):
|
||||
drawing.ensure_unique_drawing_name("UNTITLED").should_be_called().will_return("name")
|
||||
drawing.generate_drawing_name("target_view", "location_hint").should_be_called().will_return("drawing_name")
|
||||
drawing.ensure_unique_drawing_name("drawing_name").should_be_called().will_return("name")
|
||||
drawing.generate_drawing_matrix("target_view", "location_hint").should_be_called().will_return("matrix")
|
||||
drawing.create_camera("name", "matrix").should_be_called().will_return("obj")
|
||||
drawing.get_body_context().should_be_called().will_return("context")
|
||||
|
||||
@@ -32,3 +32,16 @@ class TestAddDefaultMaterial:
|
||||
ifc.run("material.add_material", name="Default").should_be_called().will_return("material")
|
||||
ifc.link("material", "obj").should_be_called()
|
||||
assert subject.add_default_material(ifc, material) == "obj"
|
||||
|
||||
|
||||
class TestLoadMaterials:
|
||||
def test_run(self, material):
|
||||
material.import_material_definitions("material_type").should_be_called()
|
||||
material.enable_editing_materials().should_be_called()
|
||||
subject.load_materials(material, "material_type")
|
||||
|
||||
|
||||
class TestDisableEditingMaterials:
|
||||
def test_run(self, material):
|
||||
material.disable_editing_materials().should_be_called()
|
||||
subject.disable_editing_materials(material)
|
||||
|
||||
@@ -34,3 +34,64 @@ class TestAddDefaultMaterialObject(NewFile):
|
||||
material = subject.add_default_material_object()
|
||||
assert isinstance(material, bpy.types.Material)
|
||||
assert material.name == "Default"
|
||||
|
||||
|
||||
class TestDisableEditingMaterials(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.BIMMaterialProperties.is_editing = True
|
||||
subject.disable_editing_materials()
|
||||
assert bpy.context.scene.BIMMaterialProperties.is_editing is False
|
||||
|
||||
|
||||
class TestEnableEditingMaterials(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.BIMMaterialProperties.is_editing = False
|
||||
subject.enable_editing_materials()
|
||||
assert bpy.context.scene.BIMMaterialProperties.is_editing is True
|
||||
|
||||
|
||||
class TestImportMaterialDefinitions(NewFile):
|
||||
def test_import_materials(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
material = ifc.createIfcMaterial(Name="Name")
|
||||
subject.import_material_definitions("IfcMaterial")
|
||||
props = bpy.context.scene.BIMMaterialProperties
|
||||
assert props.materials[0].ifc_definition_id == material.id()
|
||||
assert props.materials[0].name == "Name"
|
||||
|
||||
def test_import_material_layer_sets(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
material = ifc.createIfcMaterialLayerSet(LayerSetName="Name")
|
||||
subject.import_material_definitions("IfcMaterialLayerSet")
|
||||
props = bpy.context.scene.BIMMaterialProperties
|
||||
assert props.materials[0].ifc_definition_id == material.id()
|
||||
assert props.materials[0].name == "Name"
|
||||
|
||||
def test_import_material_profile_sets(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
material = ifc.createIfcMaterialProfileSet(Name="Name")
|
||||
subject.import_material_definitions("IfcMaterialProfileSet")
|
||||
props = bpy.context.scene.BIMMaterialProperties
|
||||
assert props.materials[0].ifc_definition_id == material.id()
|
||||
assert props.materials[0].name == "Name"
|
||||
|
||||
def test_import_material_constituent_sets(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
material = ifc.createIfcMaterialConstituentSet(Name="Name")
|
||||
subject.import_material_definitions("IfcMaterialConstituentSet")
|
||||
props = bpy.context.scene.BIMMaterialProperties
|
||||
assert props.materials[0].ifc_definition_id == material.id()
|
||||
assert props.materials[0].name == "Name"
|
||||
|
||||
def test_import_material_lists(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
material = ifc.createIfcMaterialList()
|
||||
subject.import_material_definitions("IfcMaterialList")
|
||||
props = bpy.context.scene.BIMMaterialProperties
|
||||
assert props.materials[0].ifc_definition_id == material.id()
|
||||
assert props.materials[0].name == "Unnamed"
|
||||
|
||||
Reference in New Issue
Block a user