ifcopenshell.util - make ifc_file argument optional if it can be deduced from ifc element

This commit is contained in:
Andrej730
2025-03-07 12:07:14 +05:00
parent 590288496e
commit eb0d3c38b2
4 changed files with 43 additions and 13 deletions
@@ -66,7 +66,7 @@ class Clipping:
raise Exception(f"Unexpected clipping type provided: {raw_data}")
def apply(
self, ifc_file: ifcopenshell.file, first_operand: ifcopenshell.entity_instance, unit_scale: float
self, ifc_file: Union[ifcopenshell.file, None], first_operand: ifcopenshell.entity_instance, unit_scale: float
) -> ifcopenshell.entity_instance:
"""Applies the clipping data as an IfcBooleanClippingResult to an operand
@@ -76,6 +76,9 @@ class Clipping:
:return: An IfcBooleanClippingResult which uses an IfcHalfSpaceSolid to clip the first operand
"""
if not ifc_file:
ifc_file = first_operand.file
location = ifc_file.createIfcCartesianPoint([i / unit_scale for i in self.location])
direction = ifc_file.createIfcDirection(self.normal)