mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
typing
This commit is contained in:
@@ -27,29 +27,28 @@ def assign_representation(
|
||||
) -> None:
|
||||
usecase = Usecase()
|
||||
usecase.file = file
|
||||
usecase.settings = {"product": product, "representation": representation}
|
||||
return usecase.execute()
|
||||
return usecase.execute(product, representation)
|
||||
|
||||
|
||||
class Usecase:
|
||||
file: ifcopenshell.file
|
||||
settings: dict[str, Any]
|
||||
|
||||
def execute(self) -> None:
|
||||
if self.settings["product"].is_a("IfcProduct"):
|
||||
product_type = ifcopenshell.util.element.get_type(self.settings["product"])
|
||||
def execute(self, product: ifcopenshell.entity_instance, representation: ifcopenshell.entity_instance) -> None:
|
||||
if product.is_a("IfcProduct"):
|
||||
product_type = ifcopenshell.util.element.get_type(product)
|
||||
if (
|
||||
product_type
|
||||
and product_type.RepresentationMaps
|
||||
and self.settings["representation"].RepresentationType != "MappedRepresentation"
|
||||
and representation.RepresentationType != "MappedRepresentation"
|
||||
):
|
||||
self.settings["product"] = product_type
|
||||
product = product_type
|
||||
|
||||
if self.settings["product"].is_a("IfcProduct"):
|
||||
self.assign_product_representation(self.settings["product"], self.settings["representation"])
|
||||
elif self.settings["product"].is_a("IfcTypeProduct"):
|
||||
if self.settings["product"].RepresentationMaps:
|
||||
maps = list(self.settings["product"].RepresentationMaps)
|
||||
if product.is_a("IfcProduct"):
|
||||
self.assign_product_representation(product, representation)
|
||||
elif product.is_a("IfcTypeProduct"):
|
||||
if product.RepresentationMaps:
|
||||
maps = list(product.RepresentationMaps)
|
||||
else:
|
||||
maps = []
|
||||
self.zero = self.file.createIfcCartesianPoint((0.0, 0.0, 0.0))
|
||||
@@ -60,22 +59,22 @@ class Usecase:
|
||||
"IfcRepresentationMap",
|
||||
**{
|
||||
"MappingOrigin": self.file.createIfcAxis2Placement3D(self.zero, self.z_axis, self.x_axis),
|
||||
"MappedRepresentation": self.settings["representation"],
|
||||
"MappedRepresentation": representation,
|
||||
}
|
||||
)
|
||||
)
|
||||
self.settings["product"].RepresentationMaps = maps
|
||||
product.RepresentationMaps = maps
|
||||
if self.file.schema == "IFC2X3":
|
||||
types = self.settings["product"].ObjectTypeOf
|
||||
types = product.ObjectTypeOf
|
||||
else:
|
||||
types = self.settings["product"].Types
|
||||
types = product.Types
|
||||
if types:
|
||||
for element in types[0].RelatedObjects:
|
||||
mapped_representation = ifcopenshell.api.geometry.map_representation(
|
||||
self.file, representation=self.settings["representation"]
|
||||
self.file, representation=representation
|
||||
)
|
||||
self.assign_product_representation(element, mapped_representation)
|
||||
ifcopenshell.api.owner.update_owner_history(self.file, element=self.settings["product"])
|
||||
ifcopenshell.api.owner.update_owner_history(self.file, element=product)
|
||||
|
||||
def assign_product_representation(
|
||||
self, product: ifcopenshell.entity_instance, representation: ifcopenshell.entity_instance
|
||||
|
||||
Reference in New Issue
Block a user