-
Notifications
You must be signed in to change notification settings - Fork 2
/
cache_operators.py
49 lines (33 loc) · 1.43 KB
/
cache_operators.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Operators that handle the cached Open Landscape Data"""
import bpy
DATA_FILE_NAME = 'OpenLandscapeData.xml'
class ClearCacheOperator(bpy.types.Operator):
"""Clear the Open Landscape Cached Data"""
bl_idname = "open_landscape.clear_cache"
bl_label = "Clear Cached Data"
bl_options = {"REGISTER"}
def execute(self, context: bpy.types.Context):
"""Actually clear the cached data"""
props = context.scene.open_landscape_properties
props.cached_origin_lat = 0.0
props.cached_origin_lon = 0.0
props.cached_origin_radius = 0
props.cached_openstreetmap_xml = ''
print('OpenLandscape: Cleared Cached Data')
return {'FINISHED'}
class ShowCacheOperator(bpy.types.Operator):
"""Clear the Open Landscape Cached Data"""
bl_idname = "open_landscape.show_cache"
bl_label = "Show Cached Data"
bl_options = {"REGISTER", "INTERNAL"}
def execute(self, context: bpy.types.Context):
xml_data = context.scene.open_landscape_properties.cached_openstreetmap_xml
if xml_data:
if bpy.data.texts.find(DATA_FILE_NAME) == -1:
bpy.ops.text.new()
bpy.data.texts[-1].name = DATA_FILE_NAME
bpy.data.texts[DATA_FILE_NAME].from_string(xml_data)
print('OpenLandscape: See Text Editor for Data')
else:
print('OpenLandscape: No Data found in Cache')
return {'FINISHED'}