Page Menu
Home
Search
Configure Global Search
Log In
Files
F26690
wm_export_theme.py
Public
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
codemanx
Nov 13 2013, 5:37 PM
Size
2 KB
Subscribers
None
wm_export_theme.py
View Options
import
bpy
import
os
# ExportHelper is a helper class, defines filename and
# invoke() function which calls the file selector.
from
bpy_extras.io_utils
import
ExportHelper
from
bpy.props
import
StringProperty
from
bpy.types
import
Operator
bl_info
=
{
"name"
:
"Export Theme"
,
"author"
:
"Code used written by Blender team, CoDEmanX"
,
"version"
:
(
1
,
0
,
0
),
"blender"
:
(
2
,
65
,
0
),
"location"
:
"User preferences > Themes"
,
"description"
:
"Export current theme settings to an XML preset file."
,
"warning"
:
""
,
"wiki_url"
:
""
,
"tracker_url"
:
""
,
"category"
:
"Import-Export"
}
class
WM_OT_export_theme
(
Operator
,
ExportHelper
):
"""Export current theme settings to an XML preset file"""
bl_idname
=
"wm.export_theme"
# important since its how bpy.ops.import_test.some_data is constructed
bl_label
=
"Export Theme"
# ExportHelper mixin class uses this
filename_ext
=
".xml"
filter_glob
=
StringProperty
(
default
=
"*.xml"
,
options
=
{
'HIDDEN'
},
)
@staticmethod
def
as_filename
(
name
):
# could reuse for other presets
for
char
in
" !@#$%^&*(){}:
\"
;'[]<>,.
\\
/?"
:
name
=
name
.
replace
(
char
,
'_'
)
return
name
.
lower
()
.
strip
()
def
check_name
(
self
,
filepath
):
filename
=
bpy
.
path
.
display_name_from_filepath
(
filepath
)
filename
=
self
.
as_filename
(
filename
.
strip
())
path
=
os
.
path
.
split
(
filepath
)[
0
]
splitdrive
=
os
.
path
.
splitdrive
(
path
)
path
=
splitdrive
[
1
]
if
splitdrive
[
1
]
!=
os
.
sep
else
""
filepath
=
splitdrive
[
0
]
+
path
+
os
.
sep
+
filename
+
self
.
filename_ext
return
filepath
def
execute
(
self
,
context
):
import
rna_xml
preset_subdir
=
"interface_theme"
preset_menu
=
"USERPREF_MT_interface_theme_presets"
preset_menu_class
=
getattr
(
bpy
.
types
,
preset_menu
)
ext
=
self
.
filename_ext
filepath
=
self
.
check_name
(
self
.
filepath
)
print
(
"Exporting Preset:
%r
"
%
filepath
)
rna_xml
.
xml_file_write
(
context
,
filepath
,
preset_menu_class
.
preset_xml_map
)
return
{
'FINISHED'
}
def
check
(
self
,
context
):
change_name
=
False
filepath
=
self
.
filepath
filepath
=
self
.
check_name
(
filepath
)
if
filepath
!=
self
.
filepath
:
self
.
filepath
=
filepath
change_name
=
True
return
change_name
def
menu_func_export
(
self
,
context
):
self
.
layout
.
operator
(
WM_OT_export_theme
.
bl_idname
,
text
=
"Export Theme..."
)
def
register
():
bpy
.
utils
.
register_class
(
WM_OT_export_theme
)
bpy
.
types
.
USERPREF_HT_header
.
append
(
menu_func_export
)
def
unregister
():
bpy
.
utils
.
unregister_class
(
WM_OT_export_theme
)
bpy
.
types
.
USERPREF_HT_header
.
remove
(
menu_func_export
)
if
__name__
==
"__main__"
:
register
()
File Metadata
Details
Mime Type
text/x-python
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
33/08/d74703880b696da04384e9802139
Event Timeline
Log In to Comment