[Bf-extensions-cvs] [857998f4] master: Sun position: add time and place presets, remove reset operator

Damien Picard noreply at git.blender.org
Wed Oct 28 18:51:22 CET 2020


Commit: 857998f409951f2f2454756841abd43fd456587a
Author: Damien Picard
Date:   Tue Apr 21 10:44:36 2020 +0200
Branches: master
https://developer.blender.org/rBA857998f409951f2f2454756841abd43fd456587a

Sun position: add time and place presets, remove reset operator

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

A	presets/operator/sun_position/chongqing.py
A	presets/operator/sun_position/kinshasa.py
A	presets/operator/sun_position/london.py
A	presets/operator/sun_position/new_york.py
A	presets/operator/sun_position/sao_paulo.py
A	presets/operator/sun_position/sydney.py
M	sun_position/__init__.py
M	sun_position/ui_sun.py

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

diff --git a/presets/operator/sun_position/chongqing.py b/presets/operator/sun_position/chongqing.py
new file mode 100644
index 00000000..7054bde0
--- /dev/null
+++ b/presets/operator/sun_position/chongqing.py
@@ -0,0 +1,6 @@
+import bpy
+sun_props = bpy.context.scene.sun_pos_properties
+
+sun_props.UTC_zone = 8
+sun_props.latitude = 29.558300
+sun_props.longitude = 106.567000
diff --git a/presets/operator/sun_position/kinshasa.py b/presets/operator/sun_position/kinshasa.py
new file mode 100644
index 00000000..471c7dcf
--- /dev/null
+++ b/presets/operator/sun_position/kinshasa.py
@@ -0,0 +1,6 @@
+import bpy
+sun_props = bpy.context.scene.sun_pos_properties
+
+sun_props.UTC_zone = 1
+sun_props.latitude = -4.325000
+sun_props.longitude = 15.322200
diff --git a/presets/operator/sun_position/london.py b/presets/operator/sun_position/london.py
new file mode 100644
index 00000000..649b4e6f
--- /dev/null
+++ b/presets/operator/sun_position/london.py
@@ -0,0 +1,6 @@
+import bpy
+sun_props = bpy.context.scene.sun_pos_properties
+
+sun_props.UTC_zone = 0
+sun_props.latitude = 51.507200
+sun_props.longitude = -0.127500
diff --git a/presets/operator/sun_position/new_york.py b/presets/operator/sun_position/new_york.py
new file mode 100644
index 00000000..eac57e2c
--- /dev/null
+++ b/presets/operator/sun_position/new_york.py
@@ -0,0 +1,6 @@
+import bpy
+sun_props = bpy.context.scene.sun_pos_properties
+
+sun_props.UTC_zone = -5
+sun_props.latitude = 40.661100
+sun_props.longitude = -73.943900
diff --git a/presets/operator/sun_position/sao_paulo.py b/presets/operator/sun_position/sao_paulo.py
new file mode 100644
index 00000000..fc5f4619
--- /dev/null
+++ b/presets/operator/sun_position/sao_paulo.py
@@ -0,0 +1,6 @@
+import bpy
+sun_props = bpy.context.scene.sun_pos_properties
+
+sun_props.UTC_zone = -3
+sun_props.latitude = -23.550000
+sun_props.longitude = -46.633300
diff --git a/presets/operator/sun_position/sydney.py b/presets/operator/sun_position/sydney.py
new file mode 100644
index 00000000..d93dbbbd
--- /dev/null
+++ b/presets/operator/sun_position/sydney.py
@@ -0,0 +1,6 @@
+import bpy
+sun_props = bpy.context.scene.sun_pos_properties
+
+sun_props.UTC_zone = 10
+sun_props.latitude = -33.865000
+sun_props.longitude = 151.209000
diff --git a/sun_position/__init__.py b/sun_position/__init__.py
index c1638ef6..ddbc2bc0 100644
--- a/sun_position/__init__.py
+++ b/sun_position/__init__.py
@@ -62,7 +62,6 @@ def register():
                         description="Sun Position Settings"))
     bpy.utils.register_class(properties.SunPosAddonPreferences)
     bpy.utils.register_class(ui_sun.SUNPOS_OT_AddPreset)
-    bpy.utils.register_class(ui_sun.SUNPOS_OT_DefaultPresets)
     bpy.utils.register_class(ui_sun.SUNPOS_MT_Presets)
     bpy.utils.register_class(ui_sun.SUNPOS_PT_Panel)
     bpy.utils.register_class(ui_sun.SUNPOS_PT_Location)
@@ -78,7 +77,6 @@ def unregister():
     bpy.utils.unregister_class(ui_sun.SUNPOS_PT_Location)
     bpy.utils.unregister_class(ui_sun.SUNPOS_PT_Time)
     bpy.utils.unregister_class(ui_sun.SUNPOS_MT_Presets)
-    bpy.utils.unregister_class(ui_sun.SUNPOS_OT_DefaultPresets)
     bpy.utils.unregister_class(ui_sun.SUNPOS_OT_AddPreset)
     bpy.utils.unregister_class(properties.SunPosAddonPreferences)
     del bpy.types.Scene.sun_pos_properties
diff --git a/sun_position/ui_sun.py b/sun_position/ui_sun.py
index 6dcc0905..e14d9600 100644
--- a/sun_position/ui_sun.py
+++ b/sun_position/ui_sun.py
@@ -63,40 +63,6 @@ class SUNPOS_OT_AddPreset(AddPresetBase, Operator):
     preset_subdir = "operator/sun_position"
 
 
-class SUNPOS_OT_DefaultPresets(Operator):
-    '''Copy Sun Position default presets'''
-    bl_idname = "world.sunpos_default_presets"
-    bl_label = "Copy Sun Position default presets"
-
-    def execute(self, context):
-        preset_dirpath = bpy.utils.user_resource('SCRIPTS', path="presets/operator/sun_position", create=True)
-        #                       [month, day, time, UTC, lat, lon, dst]
-        presets = {"chongqing.py": [10, 1,  7.18,  8, 29.5583,  106.567, False],
-                   "sao_paulo.py": [9,  7,  12.0, -3,  -23.55, -46.6333, False],
-                   "kinshasa.py":  [6,  30, 12.0,  1,  -4.325,  15.3222, False],
-                   "london.py":    [6,  11, 12.0,  0, 51.5072,  -0.1275, True],
-                   "new_york.py":  [7,  4,  12.0, -5, 40.6611, -73.9439, True],
-                   "sydney.py":    [1,  26, 17.6, 10, -33.865,  151.209, False]}
-
-        script = '''import bpy
-sun_props = bpy.context.scene.sun_pos_properties
-
-sun_props.month = {:d}
-sun_props.day = {:d}
-sun_props.time = {:f}
-sun_props.UTC_zone = {:d}
-sun_props.latitude = {:f}
-sun_props.longitude = {:f}
-sun_props.use_daylight_savings = {}
-'''
-
-        for path, p in presets.items():
-            print(p)
-            with open(os.path.join(preset_dirpath, path), 'w') as f:
-                f.write(script.format(*p))
-
-        return {'FINISHED'}
-
 # -------------------------------------------------------------------
 #
 #   Draw the Sun Panel, sliders, et. al.
@@ -168,7 +134,6 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
             row.menu(SUNPOS_MT_Presets.__name__, text=SUNPOS_MT_Presets.bl_label)
             row.operator(SUNPOS_OT_AddPreset.bl_idname, text="", icon='ADD')
             row.operator(SUNPOS_OT_AddPreset.bl_idname, text="", icon='REMOVE').remove_active = True
-            row.operator(SUNPOS_OT_DefaultPresets.bl_idname, text="", icon='FILE_REFRESH')
 
         col = layout.column(align=True)
         col.use_property_split = True



More information about the Bf-extensions-cvs mailing list