mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Minor fix to sun_position < Blender 4.2
This commit is contained in:
@@ -145,8 +145,8 @@ class BIM_PT_solar(bpy.types.Panel):
|
||||
row = col.row(align=True)
|
||||
box = row.box()
|
||||
|
||||
local_time = format_time(sun_props.time, sun_props.use_daylight_savings)
|
||||
utc_time = format_time(sun_props.time, sun_props.use_daylight_savings, sun_props.UTC_zone)
|
||||
local_time = sun_position.sun_calc.format_time(sun_props.time, sun_props.use_daylight_savings)
|
||||
utc_time = sun_position.sun_calc.format_time(sun_props.time, sun_props.use_daylight_savings, sun_props.UTC_zone)
|
||||
|
||||
row2 = box.row()
|
||||
row2.label(text=f"Local Time: {local_time}")
|
||||
@@ -155,8 +155,8 @@ class BIM_PT_solar(bpy.types.Panel):
|
||||
|
||||
box = row.box()
|
||||
|
||||
sunrise = format_hms(sun.sunrise)
|
||||
sunset = format_hms(sun.sunset)
|
||||
sunrise = sun_position.sun_calc.format_hms(sun_position.sun_calc.sun.sunrise)
|
||||
sunset = sun_position.sun_calc.format_hms(sun_position.sun_calc.sun.sunset)
|
||||
|
||||
row2 = box.row()
|
||||
row2.label(text=f"Sunrise: {sunrise}")
|
||||
|
||||
@@ -1121,13 +1121,15 @@ class Blender(blenderbim.core.tool.Blender):
|
||||
@classmethod
|
||||
def get_sun_position_addon(cls) -> Union[types.ModuleType, None]:
|
||||
# Check if it's installed as legacy Blender addon.
|
||||
import importlib
|
||||
|
||||
try:
|
||||
import sun_position
|
||||
sun_position = importlib.import_module("sun_position")
|
||||
except ImportError:
|
||||
sun_position = None
|
||||
|
||||
if sun_position:
|
||||
return
|
||||
return sun_position
|
||||
|
||||
# No extensions prior to 4.2.
|
||||
if bpy.app.version < (4, 2, 0):
|
||||
@@ -1136,8 +1138,6 @@ class Blender(blenderbim.core.tool.Blender):
|
||||
if sun_position:
|
||||
return sun_position
|
||||
|
||||
import importlib
|
||||
|
||||
for package_name in bpy.context.preferences.addons.keys():
|
||||
if package_name.endswith(".sun_position"):
|
||||
sun_position = importlib.import_module(package_name)
|
||||
|
||||
Reference in New Issue
Block a user