2021-01-02 17:45:36 +11:00
|
|
|
class Usecase:
|
2021-03-27 19:14:32 +11:00
|
|
|
def __init__(self, file, **settings):
|
2021-01-02 17:45:36 +11:00
|
|
|
self.file = file
|
2021-01-06 17:57:24 +11:00
|
|
|
self.settings = {
|
|
|
|
|
"shape_representation": None,
|
|
|
|
|
"styles": [],
|
|
|
|
|
"should_use_presentation_style_assignment": False,
|
|
|
|
|
}
|
2021-01-02 17:45:36 +11:00
|
|
|
for key, value in settings.items():
|
|
|
|
|
self.settings[key] = value
|
|
|
|
|
|
|
|
|
|
def execute(self):
|
2021-01-04 11:08:15 +11:00
|
|
|
if not self.settings["styles"]:
|
|
|
|
|
return []
|
2021-01-02 17:45:36 +11:00
|
|
|
self.results = []
|
|
|
|
|
for element in self.file.traverse(self.settings["shape_representation"]):
|
|
|
|
|
if not element.is_a("IfcShapeRepresentation"):
|
|
|
|
|
continue
|
|
|
|
|
for item in element.Items:
|
|
|
|
|
if not item.is_a("IfcGeometricRepresentationItem"):
|
|
|
|
|
continue
|
|
|
|
|
style = self.settings["styles"].pop(0)
|
2021-01-06 17:57:24 +11:00
|
|
|
name = style.Name
|
|
|
|
|
if self.file.schema == "IFC2X3" or self.settings["should_use_presentation_style_assignment"]:
|
|
|
|
|
style = self.file.createIfcPresentationStyleAssignment([style])
|
2021-07-10 22:06:11 +10:00
|
|
|
self.results.append(self.file.createIfcStyledItem(item, [style], name))
|
2021-01-02 17:45:36 +11:00
|
|
|
return self.results
|