mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Sun position add-on is now detected in the current session instead of needing to restart Blender
This commit is contained in:
@@ -34,10 +34,15 @@ class SolarData:
|
||||
def load(cls):
|
||||
cls.is_loaded = True
|
||||
cls.data = {
|
||||
"sun_position": cls.sun_position(),
|
||||
"sites": cls.sites(),
|
||||
"true_north": cls.true_north(),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def sun_position(cls):
|
||||
return tool.Blender.get_sun_position_addon()
|
||||
|
||||
@classmethod
|
||||
def sites(cls):
|
||||
results = []
|
||||
|
||||
@@ -28,8 +28,6 @@ from gpu_extras.batch import batch_for_shader
|
||||
from bpy_extras.view3d_utils import location_3d_to_region_2d
|
||||
from blenderbim.bim.module.light.data import SolarData
|
||||
|
||||
sun_position = tool.Blender.get_sun_position_addon()
|
||||
|
||||
|
||||
class SolarDecorator:
|
||||
is_installed = False
|
||||
@@ -149,7 +147,7 @@ class SolarDecorator:
|
||||
indices = []
|
||||
coord_offset = 0
|
||||
for h in range(24):
|
||||
analemma_verts = sun_position.sun_calc.calc_analemma(context, h)
|
||||
analemma_verts = SolarData.data["sun_position"].sun_calc.calc_analemma(context, h)
|
||||
coords.extend([origin @ v for v in analemma_verts])
|
||||
for i in range(len(analemma_verts) - 1):
|
||||
indices.append((coord_offset + i, coord_offset + i + 1))
|
||||
|
||||
@@ -36,8 +36,6 @@ from bpy.types import PropertyGroup
|
||||
from blenderbim.bim.module.light.data import SolarData
|
||||
from blenderbim.bim.module.light.decorator import SolarDecorator
|
||||
|
||||
sun_position = tool.Blender.get_sun_position_addon()
|
||||
|
||||
|
||||
def get_sites(self, context):
|
||||
if not SolarData.is_loaded:
|
||||
@@ -103,6 +101,12 @@ def update_display_sun_path(self, context):
|
||||
|
||||
|
||||
def update_sun_path():
|
||||
if not SolarData.is_loaded:
|
||||
SolarData.load()
|
||||
|
||||
if (sun_position := SolarData.data["sun_position"]) is None:
|
||||
return
|
||||
|
||||
props = bpy.context.scene.BIMSolarProperties
|
||||
sun_props = bpy.context.scene.sun_pos_properties
|
||||
props.timezone = tzfpy.get_tz(props.longitude, props.latitude)
|
||||
|
||||
@@ -21,9 +21,6 @@ import blenderbim.tool as tool
|
||||
from blenderbim.bim.module.light.data import SolarData
|
||||
|
||||
|
||||
sun_position = tool.Blender.get_sun_position_addon()
|
||||
|
||||
|
||||
class BIM_PT_radiance_exporter(bpy.types.Panel):
|
||||
"""Creates a Panel in the render properties window"""
|
||||
|
||||
@@ -121,13 +118,13 @@ class BIM_PT_solar(bpy.types.Panel):
|
||||
bl_options = {"HIDE_HEADER"}
|
||||
|
||||
def draw(self, context):
|
||||
if sun_position is None:
|
||||
self.layout.label(text="Enable 'Sun Position' addon to continue.")
|
||||
return
|
||||
|
||||
if not SolarData.is_loaded:
|
||||
SolarData.load()
|
||||
|
||||
if (sun_position := SolarData.data["sun_position"]) is None:
|
||||
self.layout.label(text="Enable 'Sun Position' Add-on To Continue", icon="ERROR")
|
||||
return
|
||||
|
||||
props = context.scene.BIMSolarProperties
|
||||
|
||||
if SolarData.data["sites"]:
|
||||
|
||||
Reference in New Issue
Block a user