From fcc4eb13708efe781a51eaee753f62f2b099d563 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 17 Oct 2024 16:07:21 +0200 Subject: [PATCH] BIM: NativeIFC 2D support - small fixes --- src/Mod/BIM/nativeifc/ifc_export.py | 3 +++ src/Mod/BIM/nativeifc/ifc_objects.py | 2 +- src/Mod/BIM/nativeifc/ifc_tools.py | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Mod/BIM/nativeifc/ifc_export.py b/src/Mod/BIM/nativeifc/ifc_export.py index daa976e7dd..ca2d3d10cd 100644 --- a/src/Mod/BIM/nativeifc/ifc_export.py +++ b/src/Mod/BIM/nativeifc/ifc_export.py @@ -234,6 +234,9 @@ def get_dimension(annotation): s = ifcopenshell.util.unit.calculate_unit_scale(annotation.file) * 1000 for rep in annotation.Representation.Representations: shape = importIFCHelper.get2DShape(rep, s, notext=True) + pl = get_placement(annotation.ObjectPlacement, scale=s) + if pl: + shape[0].Placement = pl if shape and len(shape) == 1: if len(shape[0].Vertexes) >= 2: # two-point polyline (BBIM) diff --git a/src/Mod/BIM/nativeifc/ifc_objects.py b/src/Mod/BIM/nativeifc/ifc_objects.py index d577130224..f7a890ec31 100644 --- a/src/Mod/BIM/nativeifc/ifc_objects.py +++ b/src/Mod/BIM/nativeifc/ifc_objects.py @@ -214,7 +214,7 @@ class ifc_object: else: print("DEBUG: unknown dimension curve type:",sub) elif attribute in ["DisplayLength","DisplayHeight","Depth"]: - l = w = h = 1000 + l = w = h = 1000.0 if obj.ViewObject: if obj.ViewObject.DisplayLength.Value: l = ifc_export.get_scaled_value(obj.ViewObject.DisplayLength.Value, ifcfile) diff --git a/src/Mod/BIM/nativeifc/ifc_tools.py b/src/Mod/BIM/nativeifc/ifc_tools.py index 6aa2e9dce0..d96783e771 100644 --- a/src/Mod/BIM/nativeifc/ifc_tools.py +++ b/src/Mod/BIM/nativeifc/ifc_tools.py @@ -843,6 +843,9 @@ def set_attribute(ifcfile, element, attribute, value): return False if not val1 and not val2: return False + if isinstance(val1, (tuple, list)): + if tuple(val1) == tuple(val2): + return False if val1 is None and "NOTDEFINED" in str(val2).upper(): return False if val1 is None and "UNDEFINED" in str(val2).upper(): @@ -882,12 +885,13 @@ def set_attribute(ifcfile, element, attribute, value): ): # do not consider default FreeCAD names given to unnamed alements return False - if differs(getattr(element, attribute, None),value): + if differs(getattr(element, attribute, None), value): FreeCAD.Console.PrintLog( "Changing IFC attribute value of " + str(attribute) + ": " + str(value) + + " (original value:" +str(getattr(element, attribute))+")" + "\n" ) api_run(cmd, ifcfile, product=element, attributes=attribs)