From 002ba58bad5877ad7585bb9c141bfc5df02cba67 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Wed, 6 Apr 2022 11:35:18 +0200 Subject: [PATCH] Arch: Fixed IFC import/export of dimensions --- src/Mod/Arch/exportIFC.py | 8 +++++++- src/Mod/Arch/importIFCHelper.py | 5 +++-- src/Mod/Draft/draftviewproviders/view_dimension.py | 10 +++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Mod/Arch/exportIFC.py b/src/Mod/Arch/exportIFC.py index 5449a98775..abeeda98f3 100644 --- a/src/Mod/Arch/exportIFC.py +++ b/src/Mod/Arch/exportIFC.py @@ -1378,8 +1378,14 @@ def export(exportList, filename, colors=None, preferences=None): if curves: reps.append(ifcfile.createIfcGeometricCurveSet(curves)) l = FreeCAD.Vector(vp.tbase).multiply(preferences['SCALE_FACTOR']) + zdir = None + xdir = None + if hasattr(vp,"trot"): + r = FreeCAD.Rotation(vp.trot[0],vp.trot[1],vp.trot[2],vp.trot[3]) + zdir = ifcbin.createIfcDirection(tuple(r.multVec(FreeCAD.Vector(0,0,1)))) + xdir = ifcbin.createIfcDirection(tuple(r.multVec(FreeCAD.Vector(1,0,0)))) pos = ifcbin.createIfcCartesianPoint((l.x,l.y,l.z)) - tpl = ifcbin.createIfcAxis2Placement3D(pos,None,None) + tpl = ifcbin.createIfcAxis2Placement3D(pos,zdir,xdir) if six.PY2: s = s.encode("utf8") txt = ifcfile.createIfcTextLiteral(vp.string,tpl,"LEFT") diff --git a/src/Mod/Arch/importIFCHelper.py b/src/Mod/Arch/importIFCHelper.py index 11a4ae2180..1380b2a3fe 100644 --- a/src/Mod/Arch/importIFCHelper.py +++ b/src/Mod/Arch/importIFCHelper.py @@ -860,11 +860,12 @@ def get2DShape(representation,scaling=1000): elif item.is_a("IfcTextLiteral"): pl = getPlacement(item.Placement, scaling) if pl: - t = Draft.make_text(item.Literal.split(";"), pl.Base) + t = Draft.make_text(item.Literal.split(";"), pl) if FreeCAD.GuiUp: if item.Path == "RIGHT": t.ViewObject.Justification = "Right" - return [] # TODO dirty hack... Object creation should not be done here + # do not return because there might be more than one representation + #return [] # TODO dirty hack... Object creation should not be done here elif representation.is_a() in ["IfcPolyline","IfcCircle","IfcTrimmedCurve","IfcRectangleProfileDef"]: result = getCurveSet(representation) return result diff --git a/src/Mod/Draft/draftviewproviders/view_dimension.py b/src/Mod/Draft/draftviewproviders/view_dimension.py index 41a64ea496..1ee2e7496d 100644 --- a/src/Mod/Draft/draftviewproviders/view_dimension.py +++ b/src/Mod/Draft/draftviewproviders/view_dimension.py @@ -595,10 +595,10 @@ class ViewProviderLinearDimension(ViewProviderDimensionBase): else: offset = DraftVecUtils.scaleTo(v1, 0.05) - rott = rot1 + self.trot = rot1 if hasattr(vobj, "FlipText") and vobj.FlipText: - _rott = App.Rotation(rott[0], rott[1], rott[2], rott[3]) - rott = _rott.multiply(App.Rotation(App.Vector(0, 0, 1), 180)).Q + _rott = App.Rotation(self.trot[0], self.trot[1], self.trot[2], self.trot[3]) + self.trot = _rott.multiply(App.Rotation(App.Vector(0, 0, 1), 180)).Q offset = offset.negative() # On first run the `DisplayMode` enumeration is not set, so we trap @@ -628,8 +628,8 @@ class ViewProviderLinearDimension(ViewProviderDimensionBase): self.textpos.translation.setValue([self.tbase.x, self.tbase.y, self.tbase.z]) - self.textpos.rotation = coin.SbRotation(rott[0], rott[1], - rott[2], rott[3]) + self.textpos.rotation = coin.SbRotation(self.trot[0], self.trot[1], + self.trot[2], self.trot[3]) show_unit = True if hasattr(vobj, "ShowUnit"):