You can access the value of any declared operator property within all provided methods.
The following demo is based on Templates > Python > Operator File Export. Once the execute method is called by the user (when hitting the 'Execute Some Data' button) the values/states of both user properties (in this case my_float and my_enum) are going to be printed into the console:
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"
# ExportHelper mixin class uses this
filename_ext = ".txt"
filter_glob: StringProperty(
default="*.txt",
options={'HIDDEN'},
maxlen=255, # Max internal buffer length, longer would be clamped.
)
# List of operator properties, the attributes will be assigned
# to the class instance from the operator settings before calling.
my_float: bpy.props.FloatProperty(
name="My float",
description="",
default=0.0
)
my_enum: EnumProperty(
name="Example Enum",
description="Choose between two items",
items=(
('OPT_A', "First Option", "Description one"),
('OPT_B', "Second Option", "Description two"),
),
default='OPT_A',
)
# Methods
def write_some_data(self, context, filepath, use_some_setting):
print("running write_some_data...")
f = open(filepath, 'w', encoding='utf-8')
f.write("Hello World %s" % use_some_setting)
f.close()
def execute(self, context):
# Print property values
print ("User values:", self.my_float, self.my_enum)
# Write the data
self.write_some_data(context, self.filepath, self.my_float)
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')
Also read: What do operator methods do? (poll, invoke, execute, draw & modal)
self.float_propertyif your property is part of an operator...? – brockmann Oct 11 '19 at 14:31(<built-in function FloatProperty>, {'name': 'Test float property', 'description': 'This is an example of a FloatProperty used by a UserExtension.', 'default': 0.0, 'attr': 'export_ExampleExtension_float'})This code is not executed inside an operator. This is a class with anexportmethod which is called by an operator. I want to access the property value inside theexportmethod. Sorry for my previous comment, it was very aggresive. – jjcasmar Oct 11 '19 at 20:37