mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Fix #963. Allow getting / setting north to / from IFC and Blender sun position.
This commit is contained in:
@@ -194,6 +194,8 @@ if bpy is not None:
|
||||
operator.BuildSchedule,
|
||||
operator.AddScheduleToSheet,
|
||||
operator.SetViewportShadowFromSun,
|
||||
operator.SetNorthOffset,
|
||||
operator.GetNorthOffset,
|
||||
prop.StrProperty,
|
||||
prop.Variable,
|
||||
prop.Role,
|
||||
|
||||
@@ -7,6 +7,7 @@ import logging
|
||||
import webbrowser
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.selector
|
||||
import ifcopenshell.util.geolocation
|
||||
import tempfile
|
||||
from . import export_ifc
|
||||
from . import import_ifc
|
||||
@@ -23,7 +24,7 @@ from . import helper
|
||||
from bpy_extras.io_utils import ImportHelper
|
||||
from itertools import cycle
|
||||
from mathutils import Vector, Matrix, Euler, geometry
|
||||
from math import radians, atan, tan, cos, sin, atan2
|
||||
from math import radians, atan, tan, cos, sin, atan2, pi
|
||||
from pathlib import Path
|
||||
from bpy.app.handlers import persistent
|
||||
|
||||
@@ -3845,3 +3846,25 @@ class SetViewportShadowFromSun(bpy.types.Operator):
|
||||
(0.0, 0.0, 0.0, 1.0)))
|
||||
context.scene.display.light_direction = mat.inverted() @ (context.active_object.matrix_world.to_quaternion() @ Vector((0,0,-1)))
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class SetNorthOffset(bpy.types.Operator):
|
||||
bl_idname = 'bim.set_north_offset'
|
||||
bl_label = 'Set North Offset'
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.sun_pos_properties.north_offset = radians(ifcopenshell.util.geolocation.xy2angle(
|
||||
float(bpy.context.scene.MapConversion.x_axis_ordinate),
|
||||
float(bpy.context.scene.MapConversion.x_axis_abscissa)))
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class GetNorthOffset(bpy.types.Operator):
|
||||
bl_idname = 'bim.get_north_offset'
|
||||
bl_label = 'Get North Offset'
|
||||
|
||||
def execute(self, context):
|
||||
x_angle = -context.scene.sun_pos_properties.north_offset
|
||||
bpy.context.scene.MapConversion.x_axis_abscissa = str(cos(x_angle))
|
||||
bpy.context.scene.MapConversion.x_axis_ordinate = str(sin(x_angle))
|
||||
return {'FINISHED'}
|
||||
|
||||
@@ -716,6 +716,11 @@ class BIM_PT_gis(Panel):
|
||||
row = layout.row(align=True)
|
||||
row.operator('bim.convert_local_to_global')
|
||||
|
||||
if hasattr(bpy.context.scene, 'sun_pos_properties'):
|
||||
row = layout.row(align=True)
|
||||
row.operator('bim.get_north_offset')
|
||||
row.operator('bim.set_north_offset')
|
||||
|
||||
|
||||
class BIM_PT_drawings(Panel):
|
||||
bl_label = "SVG Drawings"
|
||||
|
||||
Reference in New Issue
Block a user