From ee7ea5445a883168fb0eb594faaf1b9f98214316 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sat, 30 May 2020 19:40:05 +1000 Subject: [PATCH] Covetool now reads north angle from project geolocation --- .../blenderbim/bim/module/covetool/operator.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ifcblenderexport/blenderbim/bim/module/covetool/operator.py b/src/ifcblenderexport/blenderbim/bim/module/covetool/operator.py index 96af3775c4..8f0ab7a371 100644 --- a/src/ifcblenderexport/blenderbim/bim/module/covetool/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/module/covetool/operator.py @@ -1,5 +1,6 @@ import bpy import json +from math import degrees, atan2 from .api import Api @@ -81,7 +82,7 @@ class RunAnalysis(bpy.types.Operator): data = { 'run': bpy.context.scene.CoveToolProperties.projects[bpy.context.scene.CoveToolProperties.active_project_index].run_set, 'source': 'BlenderBIM', - 'rotation_angle': 0, + 'rotation_angle': self.get_rotation_angle(), **self.inputs } result = api.post_request('run-values', data) @@ -89,6 +90,18 @@ class RunAnalysis(bpy.types.Operator): covetool_results.write(json.dumps(result, indent=4)) return {'FINISHED'} + def get_rotation_angle(self): + if not bpy.context.scene.BIMProperties.has_georeferencing \ + or not bpy.context.scene.MapConversion.x_axis_abscissa \ + or not bpy.context.scene.MapConversion.x_axis_ordinate: + return 0 + rotation = -1 * degrees(atan2( + float(bpy.context.scene.MapConversion.x_axis_ordinate), + float(bpy.context.scene.MapConversion.x_axis_abscissa))) + if rotation < 0: + rotation = 360 - rotation + return rotation + def parse_objects(self): for obj in bpy.context.visible_objects: covetool_category = self.get_covetool_category(obj)