Page Menu
Home
Search
Configure Global Search
Log In
Files
F9807852
operator_file_export_bug-enum.py
Félix (Miadim)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Félix (Miadim)
Feb 16 2021, 11:33 AM
Size
1 KB
Subscribers
None
operator_file_export_bug-enum.py
View Options
import
bpy
# 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
,
BoolProperty
,
EnumProperty
from
bpy.types
import
Operator
class
ExportSomeData
(
Operator
,
ExportHelper
):
"""This appears in the tooltip of the operator and in the generated docs"""
bl_idname
=
"export_test.some_data"
# important since its how bpy.ops.import_test.some_data is constructed
bl_label
=
"Export Some Data"
filter_glob
:
StringProperty
(
default
=
"*.txt"
,
options
=
{
'HIDDEN'
},
maxlen
=
255
,
# Max internal buffer length, longer would be clamped.
)
filename_ext
:
EnumProperty
(
name
=
"Example Enum"
,
description
=
"Choose between two items"
,
items
=
(
(
'.txt'
,
"Text file"
,
"Description one"
),
(
'.py'
,
"Python file"
,
"Description two"
),
),
default
=
'.txt'
,
)
def
execute
(
self
,
context
):
self
.
report
(
type
=
{
"INFO"
},
message
=
self
.
filepath
)
return
{
'FINISHED'
}
# Only needed if you want to add into a dynamic menu
def
menu_func_export
(
self
,
context
):
self
.
layout
.
operator
(
ExportSomeData
.
bl_idname
,
text
=
"Text Export Operator"
)
def
register
():
bpy
.
utils
.
register_class
(
ExportSomeData
)
bpy
.
types
.
TOPBAR_MT_file_export
.
append
(
menu_func_export
)
def
unregister
():
bpy
.
utils
.
unregister_class
(
ExportSomeData
)
bpy
.
types
.
TOPBAR_MT_file_export
.
remove
(
menu_func_export
)
if
__name__
==
"__main__"
:
register
()
# test call
bpy
.
ops
.
export_test
.
some_data
(
'INVOKE_DEFAULT'
)
File Metadata
Details
Attached
Mime Type
text/x-python
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b7/29/256612f985b813003e8f7460b4d8
Attached To
T85688: ExportHelper: filename_ext change is appended to the previous name + ext instead of changing ext
Event Timeline
Log In to Comment