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'
This commit is contained in:
Andrej730
2024-06-10 14:01:40 +05:00
parent 6cab7d964e
commit d56da70cae
@@ -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