Skip to content

Commit

Permalink
Arch: import IFC, add commen to True North calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Jan 10, 2020
1 parent 9270322 commit fa6513d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -837,6 +837,11 @@ def insert(filename,docname,skip=[],only=[],root=None,preferences=None):
project = product.Decomposes[0].RelatingObject
modelRC = next((rc for rc in project.RepresentationContexts if rc.ContextType == "Model"), None)
if modelRC and modelRC.TrueNorth:
# If the y-part of TrueNorth is 0, then the x-part should be checked.
# Declination would be -90° if x >0 and +90° if x < 0
# Only if x==0 then we can not determine TrueNorth.
# But that would actually be an invalid IFC file, because the magnitude
# of the (twodimensional) direction vector for TrueNorth shall be greater than zero.
(x, y) = modelRC.TrueNorth.DirectionRatios[:2]
obj.Declination = ((math.degrees(math.atan2(y,x))-90+180)%360)-180
if (FreeCAD.GuiUp):
Expand Down

0 comments on commit fa6513d

Please sign in to comment.