diff --git a/src/Mod/BIM/nativeifc/ifc_generator.py b/src/Mod/BIM/nativeifc/ifc_generator.py index 874010368e..31b9a13396 100644 --- a/src/Mod/BIM/nativeifc/ifc_generator.py +++ b/src/Mod/BIM/nativeifc/ifc_generator.py @@ -339,9 +339,12 @@ def get_decomposed_elements(element, obj=None): else: # add child elements that are not yet rendered child_ids = [c.StepId for c in obj.Group if hasattr(c, "StepId")] - for child in ifcopenshell.util.element.get_decomposition( - element, is_recursive=False - ): + try: + dec = ifcopenshell.util.element.get_decomposition(element, is_recursive=False) + except: + # older version of IfcOpenShell + dec = ifcopenshell.util.element.get_decomposition(element) + for child in dec: if child.id() not in child_ids: if child not in result: result.append(child) diff --git a/src/Mod/BIM/nativeifc/ifc_tools.py b/src/Mod/BIM/nativeifc/ifc_tools.py index ea3ae40eaf..52a50551c4 100644 --- a/src/Mod/BIM/nativeifc/ifc_tools.py +++ b/src/Mod/BIM/nativeifc/ifc_tools.py @@ -1000,7 +1000,11 @@ def deaggregate(obj, parent): element = get_ifc_element(obj) if not element: return - api_run("aggregate.unassign_object", ifcfile, product=element) + try: + api_run("aggregate.unassign_object", ifcfile, products=[element]) + except: + # older version of ifcopenshell + api_run("aggregate.unassign_object", ifcfile, product=element) parent.Proxy.removeObject(parent, obj) @@ -1166,21 +1170,43 @@ def create_relationship(old_obj, obj, parent, element, ifcfile): ) elif parent_element.Decomposes: container = parent_element.Decomposes[0].RelatingObject + try: + uprel = api_run( + "aggregate.assign_object", + ifcfile, + products=[element], + relating_object=container, + ) + except: + # older version of ifcopenshell + uprel = api_run( + "aggregate.assign_object", + ifcfile, + product=element, + relating_object=container, + ) + # case 3: element aggregated inside other element + else: + try: + api_run("aggregate.unassign_object", ifcfile, products=[element]) + except: + # older version of ifcopenshell + api_run("aggregate.unassign_object", ifcfile, product=element) + try: + uprel = api_run( + "aggregate.assign_object", + ifcfile, + products=[element], + relating_object=parent_element, + ) + except: + # older version of ifcopenshell uprel = api_run( "aggregate.assign_object", ifcfile, product=element, - relating_object=container, + relating_object=parent_element, ) - # case 3: element aggregated inside other element - else: - api_run("aggregate.unassign_object", ifcfile, product=element) - uprel = api_run( - "aggregate.assign_object", - ifcfile, - product=element, - relating_object=parent_element, - ) if hasattr(parent.Proxy, "addObject"): parent.Proxy.addObject(parent, obj) return uprel