2021-03-27 22:52:52 +11:00
|
|
|
import ifcopenshell.api
|
2021-03-25 10:48:31 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Usecase:
|
2021-03-27 19:14:32 +11:00
|
|
|
def __init__(self, file, **settings):
|
2021-03-25 10:48:31 +11:00
|
|
|
self.file = file
|
|
|
|
|
self.settings = {"product": None}
|
|
|
|
|
for key, value in settings.items():
|
|
|
|
|
self.settings[key] = value
|
|
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
|
representations = []
|
|
|
|
|
if self.settings["product"].is_a("IfcProduct"):
|
|
|
|
|
if self.settings["product"].Representation:
|
|
|
|
|
representations = self.settings["product"].Representation.Representations or []
|
|
|
|
|
else:
|
|
|
|
|
representations = []
|
|
|
|
|
elif self.settings["product"].is_a("IfcTypeProduct"):
|
|
|
|
|
representations = [rm.MappedRepresentation for rm in self.settings["product"].RepresentationMaps or []]
|
|
|
|
|
for representation in representations:
|
2021-05-14 20:19:30 +10:00
|
|
|
ifcopenshell.api.run(
|
|
|
|
|
"geometry.unassign_representation",
|
|
|
|
|
self.file,
|
|
|
|
|
**{"product": self.settings["product"], "representation": representation}
|
2021-03-27 22:52:52 +11:00
|
|
|
)
|
2021-04-05 21:18:49 +10:00
|
|
|
ifcopenshell.api.run("geometry.remove_representation", self.file, **{"representation": representation})
|
2021-05-14 20:19:30 +10:00
|
|
|
for opening in getattr(self.settings["product"], "HasOpenings", []) or []:
|
2021-05-12 22:20:58 +10:00
|
|
|
ifcopenshell.api.run("void.remove_opening", self.file, opening=opening.RelatedOpeningElement)
|
2021-05-14 20:19:30 +10:00
|
|
|
|
|
|
|
|
if self.settings["product"].is_a("IfcGrid"):
|
|
|
|
|
for axis in (
|
|
|
|
|
self.settings["product"].UAxes + self.settings["product"].VAxes + (self.settings["product"].WAxes or ())
|
|
|
|
|
):
|
|
|
|
|
ifcopenshell.api.run("grid.remove_grid_axis", self.file, axis=axis)
|
|
|
|
|
|
2021-03-25 10:48:31 +11:00
|
|
|
# TODO: remove object placement and other relationships
|
|
|
|
|
self.file.remove(self.settings["product"])
|