#2111 New feature to select by style and see style usage

This commit is contained in:
Dion Moult
2022-05-08 18:03:18 +10:00
parent 910d189f35
commit 93fd3f97e3
12 changed files with 242 additions and 51 deletions
@@ -75,3 +75,13 @@ Scenario: Disable editing styles
And I press "bim.load_styles(style_type='IfcSurfaceStyle')"
When I press "bim.disable_editing_style"
Then nothing happens
Scenario: Select by style
Given an empty IFC project
And I add a cube
And I add a material
And I press "bim.add_style"
And I press "bim.load_styles(style_type='IfcSurfaceStyle')"
And the variable "style" is "{ifc}.by_type('IfcSurfaceStyle')[0].id()"
When I press "bim.select_by_style(style={style})"
Then nothing happens
+26
View File
@@ -95,6 +95,20 @@ class TestGetContext(NewFile):
assert subject.get_context("obj") == context
class TestGetElementsByStyle(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
style = ifc.createIfcSurfaceStyle()
item = ifc.createIfcExtrudedAreaSolid()
ifc.createIfcStyledItem(Item=item, Styles=[style])
element.Representation = ifc.createIfcProductDefinitionShape(
Representations=[ifc.createIfcShapeRepresentation(Items=[item])]
)
assert subject.get_elements_by_style(style) == {element}
class TestGetName(NewFile):
def test_run(self):
assert subject.get_name(bpy.data.materials.new("Material")) == "Material"
@@ -426,3 +440,15 @@ class TestIsEditingStyles(NewFile):
subject.is_editing_styles() is False
bpy.context.scene.BIMStylesProperties.is_editing = True
subject.is_editing_styles() 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