I have this operator code which I call with layout.operator("wm_filetype_source_operator") function in my Panel class:
import bpy
class EasyImport_OT_File_Type_Op(bpy.types.Operator):
bl_label = "File Type"
bl_idname = "wm.filetype_source_operator"
filetype_enum : bpy.props.EnumProperty(
name = "",
description = "Select an Source",
items = [
('OP1', "FBX", "Set FBX as File Type"),
('OP2', "GLTF", "Set GLTF as File Type"),
('OP3', "BLEND", "Set BLEND as File Type"),
('OP4', "ABC", "Set ABC as File Type")
]
)
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self)
def draw(self, context):
layout = self.layout
layout.prop(self, "filetype_enum")
def execute(self, context):
global filetype
if self.filetype_enum == 'OP1':
filetype = 'FBX'
elif self.filetype_enum == 'OP2':
filetype = 'GLTF'
elif self.filetype_enum == 'OP3':
filetype = 'BLEND'
elif self.filetype_enum == 'OP4':
filetype = 'ABC'
return {'FINISHED'}
The script works fine, but I cannot figure out how to save the filetype variable outside of the function.
So far I have tried the following:
Set
filetypevariable toglobalDefine the
filetypevariable outside the class and set it toglobalReturn the
filetypevariable
None have worked and there doesn't seem to be any info on the doc about how to do this
