mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 22:16:41 +00:00
You can now select elements by material in the material manager.
This commit is contained in:
@@ -110,3 +110,12 @@ Scenario: Assign material - Assign a material profile set
|
||||
When I set "active_object.BIMObjectMaterialProperties.material_type" to "IfcMaterialProfileSet"
|
||||
And I press "bim.assign_material"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Select by material
|
||||
Scenario: Load materials - then add material
|
||||
Given an empty IFC project
|
||||
And I press "bim.load_materials"
|
||||
And I press "bim.add_material(obj='')"
|
||||
And the variable "material" is "{ifc}.by_type('IfcMaterial')[0].id()"
|
||||
When I press "bim.select_by_material(material={material})"
|
||||
Then nothing happens
|
||||
|
||||
@@ -147,3 +147,10 @@ class TestDisableEditingMaterials:
|
||||
def test_run(self, material):
|
||||
material.disable_editing_materials().should_be_called()
|
||||
subject.disable_editing_materials(material)
|
||||
|
||||
|
||||
class TestSelectByMaterial:
|
||||
def test_run(self, material):
|
||||
material.get_elements_by_material("material").should_be_called().will_return("elements")
|
||||
material.select_elements("elements").should_be_called()
|
||||
subject.select_by_material(material, material="material")
|
||||
|
||||
@@ -68,6 +68,16 @@ class TestGetActiveMaterialType(NewFile):
|
||||
assert subject.get_active_material_type() == "IfcMaterialLayerSet"
|
||||
|
||||
|
||||
class TestGetElementsByMaterial(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
material = ifcopenshell.api.run("material.add_material", ifc)
|
||||
ifcopenshell.api.run("material.assign_material", ifc, product=element, material=material)
|
||||
assert subject.get_elements_by_material(material) == {element}
|
||||
|
||||
|
||||
class TestGetName(NewFile):
|
||||
def test_run(self):
|
||||
assert subject.get_name(bpy.data.materials.new("Material")) == "Material"
|
||||
@@ -131,3 +141,15 @@ class TestIsEditingMaterials(NewFile):
|
||||
subject.is_editing_materials() is False
|
||||
bpy.context.scene.BIMMaterialProperties.is_editing = True
|
||||
subject.is_editing_materials() is True
|
||||
|
||||
|
||||
class TestSelectElements(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc().set(ifc)
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcPump")
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
tool.Ifc.link(element, obj)
|
||||
subject.select_elements([element])
|
||||
assert obj in bpy.context.selected_objects
|
||||
|
||||
Reference in New Issue
Block a user