[Bf-extensions-cvs] [7a41cf88] master: Sun Position: add handler to force some prop updates on scene load

Damien Picard noreply at git.blender.org
Sun Jan 8 02:53:07 CET 2023


Commit: 7a41cf88cfc2967e814d1d32606fe3bbb168fb4e
Author: Damien Picard
Date:   Sat Jan 7 23:08:52 2023 +0100
Branches: master
https://developer.blender.org/rBA7a41cf88cfc2967e814d1d32606fe3bbb168fb4e

Sun Position: add handler to force some prop updates on scene load

===================================================================

M	sun_position/__init__.py
M	sun_position/draw.py

===================================================================

diff --git a/sun_position/__init__.py b/sun_position/__init__.py
index 5b2a89ce..0ec83bdb 100644
--- a/sun_position/__init__.py
+++ b/sun_position/__init__.py
@@ -16,7 +16,7 @@
 bl_info = {
     "name": "Sun Position",
     "author": "Michael Martin",
-    "version": (3, 1, 2),
+    "version": (3, 1, 3),
     "blender": (3, 0, 0),
     "location": "World > Sun Position",
     "description": "Show sun position with objects and/or sky texture",
@@ -35,6 +35,7 @@ else:
     from . import properties, ui_sun, hdr, translations
 
 import bpy
+from bpy.app.handlers import persistent
 
 
 register_classes, unregister_classes = bpy.utils.register_classes_factory(
@@ -44,6 +45,12 @@ register_classes, unregister_classes = bpy.utils.register_classes_factory(
      ui_sun.SUNPOS_PT_Location, ui_sun.SUNPOS_PT_Time, hdr.SUNPOS_OT_ShowHdr))
 
 
+ at persistent
+def sun_scene_handler(scene):
+    sun_props = bpy.context.scene.sun_pos_properties
+    sun_props.show_north = sun_props.show_north
+
+
 def register():
     register_classes()
     bpy.types.Scene.sun_pos_properties = (
@@ -51,10 +58,12 @@ def register():
                                   name="Sun Position",
                                   description="Sun Position Settings"))
     bpy.app.handlers.frame_change_post.append(sun_calc.sun_handler)
+    bpy.app.handlers.load_post.append(sun_scene_handler)
     bpy.app.translations.register(__name__, translations.translations_dict)
 
 def unregister():
     bpy.app.translations.unregister(__name__)
     bpy.app.handlers.frame_change_post.remove(sun_calc.sun_handler)
+    bpy.app.handlers.load_post.remove(sun_scene_handler)
     del bpy.types.Scene.sun_pos_properties
     unregister_classes()
diff --git a/sun_position/draw.py b/sun_position/draw.py
index 2324b417..d2dbaaaf 100644
--- a/sun_position/draw.py
+++ b/sun_position/draw.py
@@ -87,4 +87,3 @@ else:
         elif _north_handle is not None:
             bpy.types.SpaceView3D.draw_handler_remove(_north_handle, 'WINDOW')
             _north_handle = None
-        context.area.tag_redraw()



More information about the Bf-extensions-cvs mailing list