forked from Mwni/blender-animation-retargeting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loadsave.py
50 lines (37 loc) · 1013 Bytes
/
loadsave.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
50
import bpy
import json
from bpy_extras.io_utils import ExportHelper, ImportHelper
from .utilfuncs import *
def draw_panel(layout):
row = layout.row()
row.operator('retarget.load', icon='FILEBROWSER')
row.operator('retarget.save', icon='FILE_TICK')
class LoadOperator(bpy.types.Operator, ImportHelper):
bl_idname = 'retarget.load'
bl_label = 'Load Config'
filter_glob: bpy.props.StringProperty(
default='*.rtconf',
options={'HIDDEN'},
maxlen=255
)
def execute(self, context):
with open(self.filepath, 'r') as f:
state().from_serialized(json.load(f))
return {'FINISHED'}
class SaveOperator(bpy.types.Operator, ExportHelper):
bl_idname = 'retarget.save'
bl_label = 'Save Config'
filename_ext = '.rtconf'
filter_glob: bpy.props.StringProperty(
default='*.rtconf',
options={'HIDDEN'},
maxlen=255
)
def execute(self, context):
with open(self.filepath, 'w') as f:
f.write(json.dumps(state().serialize()))
return {'FINISHED'}
classes = (
LoadOperator,
SaveOperator
)