From 703aa04b9a9725e1f7e2899d0ecea320a88972c7 Mon Sep 17 00:00:00 2001 From: hlg Date: Wed, 24 Jul 2019 16:28:21 +0200 Subject: [PATCH] Arch: populate and read compass rotation from and to IFC RC true north --- src/Mod/Arch/ArchSite.py | 4 ++-- src/Mod/Arch/importIFC.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Mod/Arch/ArchSite.py b/src/Mod/Arch/ArchSite.py index 78e1fccf73..f7753dcd5f 100644 --- a/src/Mod/Arch/ArchSite.py +++ b/src/Mod/Arch/ArchSite.py @@ -877,8 +877,8 @@ class _ViewProviderSite: if not hasattr(vobj, 'UpdateDeclination') or not vobj.UpdateDeclination: return compassRotation = vobj.CompassRotation.Value - siteRotation = math.degrees(obj.Placement.Rotation.Angle) - obj.Declination = compassRotation + siteRotation + siteRotation = math.degrees(vobj.Object.Placement.Rotation.Angle) # This assumes Rotation.axis = (0,0,1) + vobj.Object.Declination = compassRotation + siteRotation def addTrueNorthRotation(self): diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index d2a049420e..d42f15b33d 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -920,6 +920,12 @@ def insert(filename,docname,skip=[],only=[],root=None): obj.Country = product.SiteAddress.Country if product.SiteAddress.PostalCode: obj.PostalCode = product.SiteAddress.PostalCode + project = product.Decomposes[0].RelatingObject + modelRC = next((rc for rc in project.RepresentationContexts if rc.ContextType == "Model"), None) + if modelRC and modelRC.TrueNorth: + obj.Declination = -math.degrees(math.atan(modelRC.TrueNorth.DirectionRatios[0] / modelRC.TrueNorth.DirectionRatios[1])) + if(FreeCAD.GuiUp): + obj.ViewObject.CompassRotation.Value = obj.Declination try: progressbar.next(True) @@ -1538,6 +1544,8 @@ def export(exportList,filename,colors=None): context = ifcfile.by_type("IfcGeometricRepresentationContext")[0] project = ifcfile.by_type("IfcProject")[0] objectslist = Draft.getGroupContents(exportList,walls=True,addgroups=True) + trueNorthX = math.tan(-Draft.getObjectsOfType(objectslist, "Site")[0].Declination.getValueAs(FreeCAD.Units.Radian)) # we assume one site and one representation context only + context.TrueNorth.DirectionRatios = (trueNorthX, 1., 1.) annotations = [] for obj in objectslist: if obj.isDerivedFrom("Part::Part2DObject"):