From d56da70caef9e7ac6016e00682f3fc03affc9fd3 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 10 Jun 2024 14:01:40 +0500 Subject: [PATCH] sequence.assign_recurrence_pattern - fix bug assigning pattern to a task time recurring It wasn't considering that IfcTaskTimeRecurring might be just created and IfcTaskTimeRecurring.Recurrence is None resulting in error below File "\api\sequence\assign_recurrence_pattern.py", line 120, in assign_recurrence_pattern if len(file.get_inverse(settings["parent"].Recurrence)) == 1: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "\file.py", line 524, in get_inverse inverses = [entity_instance(e, self) for e in self.wrapped_data.get_inverse(inst.wrapped_data)] AttributeError: 'NoneType' object has no attribute 'wrapped_data' --- .../ifcopenshell/api/sequence/assign_recurrence_pattern.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_recurrence_pattern.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_recurrence_pattern.py index 278016bde0..12fe037cc4 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_recurrence_pattern.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/assign_recurrence_pattern.py @@ -117,7 +117,7 @@ def assign_recurrence_pattern( file.remove(settings["parent"].RecurrencePattern) settings["parent"].RecurrencePattern = recurrence elif settings["parent"].is_a("IfcTaskTimeRecurring"): - if len(file.get_inverse(settings["parent"].Recurrence)) == 1: - file.remove(settings["parent"].Recurrence) + if recurrence_old := settings["parent"].Recurrence and len(file.get_inverse(recurrence_old)) == 1: + file.remove(recurrence_old) settings["parent"].Recurrence = recurrence return recurrence