Merge branch 'v0.8.0' into fix-ifccircle-ifcellipse-processing

This commit is contained in:
Thomas Krijnen
2024-09-12 20:18:57 +02:00
committed by GitHub
91 changed files with 3282 additions and 1718 deletions
@@ -445,7 +445,7 @@ def get_elements_by_pset(pset: ifcopenshell.entity_instance) -> set[ifcopenshell
"""Retrieve the elements (or element types) that are using the provided property set."""
is_ifc2x3 = pset.file.schema == "IFC2X3"
elements = set()
if pset.is_a("IfcPropertySet"):
if pset.is_a("IfcPropertySet") or pset.is_a("IfcQuantitySet"):
rels = pset.PropertyDefinitionOf if is_ifc2x3 else pset.DefinesOccurrence
for rel in rels:
elements.update(rel.RelatedObjects)
@@ -166,9 +166,9 @@ def get_quantity(resource: ifcopenshell.entity_instance) -> float:
return duration.total_seconds() / 3600
def get_parent_cost(resource: ifcopenshell.entity_instance) -> Union[None, tuple[float, Union[str, None]]]:
if not resource.Nests:
def get_parent_cost(resource: ifcopenshell.entity_instance) -> Union[tuple[float, Union[str, None]], None]:
if not (nests := resource.Nests):
return
else:
cost = get_cost(resource.Nests[0].RelatingObject)
cost = get_cost(nests[0].RelatingObject)
return cost
@@ -36,7 +36,18 @@ RECURRENCE_TYPE = Literal[
]
def derive_date(task, attribute_name, date=None, is_earliest=False, is_latest=False):
def derive_date(
task: ifcopenshell.entity_instance,
attribute_name: str,
date=None,
is_earliest: bool = False,
is_latest: bool = False,
):
"""
:param task: IfcTask.
"""
if task.TaskTime:
current_date = (
ifcopenshell.util.date.ifc2datetime(getattr(task.TaskTime, attribute_name))
@@ -268,7 +279,7 @@ def get_task_work_schedule(task: ifcopenshell.entity_instance) -> Union[ifcopens
def get_nested_tasks(task: ifcopenshell.entity_instance) -> list[ifcopenshell.entity_instance]:
return [object for rel in task.IsNestedBy or [] for object in rel.RelatedObjects]
return [object for rel in task.IsNestedBy or [] for object in rel.RelatedObjects if object.is_a("IfcTask")]
def get_parent_task(task: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
@@ -448,12 +459,9 @@ def get_related_products(
"""Gets the related products being output by a task
:param relating_product: One of the products already output by the task.
:type relating_product: ifcopenshell.entity_instance, optional
:param related_object: The IfcTask that you want to get all the related
products for.
:type related_object: ifcopenshell.entity_instance, optional
:return: A set of IfcProducts output by the IfcTask.
:rtype: set[ifcopenshell.entity_instance]
Example:
@@ -478,17 +486,18 @@ def get_related_products(
products = ifcopenshell.util.sequence.get_related_products(related_object=task)
"""
assert relating_product or related_object, "Either relating_product or related_object must be provided."
products = set()
related_object = None
if related_object:
related_object = related_object
elif relating_product:
if not related_object and relating_product:
for reference in relating_product.ReferencedBy:
if reference.is_a("IfcRelAssignsToProduct"):
related_object = reference.RelatedObjects[0]
if related_object:
assignments = related_object.HasAssignments
for assignment in assignments:
if assignment.is_a("IfcRelAssignsToProduct"):
products.add(assignment.RelatingProduct.id())
return products
@@ -368,6 +368,7 @@ class ShapeBuilder:
"ProfileType": profile_type,
"OuterCurve": outer_curve,
}
if self.file.schema == "IFC2X3":
kwargs["Position"] = self.create_axis2_placement_2d()