mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Fix potential instability when assigning types and synchronising Blender geometry
This commit is contained in:
@@ -14,11 +14,8 @@ class Data:
|
||||
cls.products[product_id] = []
|
||||
product = file.by_id(product_id)
|
||||
representations = []
|
||||
if product.is_a("IfcProduct"):
|
||||
if product.Representation:
|
||||
representations = product.Representation.Representations
|
||||
else:
|
||||
representations = []
|
||||
if product.is_a("IfcProduct") and product.Representation:
|
||||
representations = product.Representation.Representations
|
||||
elif product.is_a("IfcTypeProduct"):
|
||||
representations = [rm.MappedRepresentation for rm in product.RepresentationMaps or []]
|
||||
for representation in representations:
|
||||
|
||||
@@ -52,3 +52,30 @@ class Usecase:
|
||||
"RelatingType": self.settings["relating_type"],
|
||||
}
|
||||
)
|
||||
|
||||
self.map_representations()
|
||||
|
||||
def map_representations(self):
|
||||
if not self.settings["relating_type"].RepresentationMaps:
|
||||
return
|
||||
representations = []
|
||||
if self.settings["related_object"].Representation:
|
||||
representations = self.settings["related_object"].Representation.Representations
|
||||
for representation in representations:
|
||||
# TODO: check if this is right? Surely this can be a single usecase?
|
||||
ifcopenshell.api.run(
|
||||
"geometry.unassign_representation",
|
||||
self.file,
|
||||
**{"product": self.settings["related_object"], "representation": representation}
|
||||
)
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, **{"representation": representation})
|
||||
for representation_map in self.settings["relating_type"].RepresentationMaps:
|
||||
representation = representation_map.MappedRepresentation
|
||||
result = ifcopenshell.api.run(
|
||||
"geometry.map_representation", self.file, **{"representation": representation}
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.assign_representation",
|
||||
self.file,
|
||||
**{"product": self.settings["related_object"], "representation": result}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user