mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
style.assign_representation_styles to replace previously assigned styles
as probably in the most cases user would want 1 style per 1 representation item After this it's finally possible in BBIM to assign styles to representation items through the materials: https://imgur.com/a/cgiJ1KV
This commit is contained in:
@@ -38,14 +38,22 @@ class TestAssignRepresentationStyles(test.bootstrap.IFC4):
|
||||
)
|
||||
assert item.StyledByItem[0].Styles == (style,)
|
||||
|
||||
# reusing existing styled item
|
||||
style2 = self.file.createIfcSurfaceStyle()
|
||||
# reusing existing styled item for different style type
|
||||
style2 = self.file.createIfcFillAreaStyle()
|
||||
ifcopenshell.api.run(
|
||||
"style.assign_representation_styles", self.file, styles=[style2], shape_representation=representation
|
||||
)
|
||||
assert item.StyledByItem[0].Styles == (style, style2)
|
||||
assert len(self.file.by_type("IfcStyledItem")) == 1
|
||||
|
||||
# replacing existing style of the same type
|
||||
style3 = self.file.createIfcSurfaceStyle()
|
||||
ifcopenshell.api.run(
|
||||
"style.assign_representation_styles", self.file, styles=[style3], shape_representation=representation
|
||||
)
|
||||
assert item.StyledByItem[0].Styles == (style2, style3)
|
||||
assert len(self.file.by_type("IfcStyledItem")) == 1
|
||||
|
||||
def test_assign_using_style_assignment(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
product_shape = self.file.createIfcProductDefinitionShape()
|
||||
@@ -68,8 +76,8 @@ class TestAssignRepresentationStyles(test.bootstrap.IFC4):
|
||||
assert style_assignment.Styles == (style,)
|
||||
assert item.StyledByItem[0].Styles == (style_assignment,)
|
||||
|
||||
# reusing existing styled item and style assignment
|
||||
style2 = self.file.createIfcSurfaceStyle()
|
||||
# reusing existing styled item for different style type
|
||||
style2 = self.file.createIfcFillAreaStyle()
|
||||
ifcopenshell.api.run(
|
||||
"style.assign_representation_styles",
|
||||
self.file,
|
||||
@@ -83,6 +91,21 @@ class TestAssignRepresentationStyles(test.bootstrap.IFC4):
|
||||
assert item.StyledByItem[0].Styles[0].Styles == (style, style2)
|
||||
assert len(self.file.by_type("IfcStyledItem")) == 1
|
||||
|
||||
# replacing existing style of the same type
|
||||
style3 = self.file.createIfcSurfaceStyle()
|
||||
ifcopenshell.api.run(
|
||||
"style.assign_representation_styles",
|
||||
self.file,
|
||||
styles=[style3],
|
||||
shape_representation=representation,
|
||||
should_use_presentation_style_assignment=True,
|
||||
)
|
||||
|
||||
assert len(self.file.by_type("IfcPresentationStyleAssignment")) == 1
|
||||
assert item.StyledByItem[0].Styles == (style_assignment,)
|
||||
assert item.StyledByItem[0].Styles[0].Styles == (style2, style3)
|
||||
assert len(self.file.by_type("IfcStyledItem")) == 1
|
||||
|
||||
|
||||
class TestAssignRepresentationStylesIFC2X3(test.bootstrap.IFC2X3):
|
||||
def test_run(self):
|
||||
|
||||
Reference in New Issue
Block a user