context.add_fileselect(self.__operator__). To allow file selector, I made the following changes: - moved property definition funcs (FloatProperty, etc.) to "bpy.props" to make them accessible from io scripts. Previously they were only accessible in scripts running from Text Editor. - added the "__operator__" instance attribute to py operators. The value is RNA operator pointer. Note that "context.add_fileselect" changes were mistakenly committed with my last merge.
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
|
|
import bpy
|
|
|
|
class SCRIPT_OT_export_obj(bpy.types.Operator):
|
|
'''Operator documentation text, will be used for the operator tooltip and python docs.'''
|
|
__label__ = 'Export OBJ'
|
|
|
|
# List of operator properties, the attributes will be assigned
|
|
# to the class instance from the operator settings before calling.
|
|
__props__ = [
|
|
bpy.props["StringProperty"](attr="filename", name="filename", default="/tmp")
|
|
# FloatProperty(attr="setting_1", name="Example 1", default=10.0, min=0, max=10, description="Add info here"),
|
|
# StringProperty(attr="filename")
|
|
]
|
|
|
|
def debug(self, message):
|
|
print("{0}: {1}".format(self.__class__.__name__, message))
|
|
|
|
def exec(self, context):
|
|
# print(self.setting_1)
|
|
self.debug("exec")
|
|
self.debug("filename = " + self.filename)
|
|
return ('FINISHED',)
|
|
|
|
def invoke(self, context, event):
|
|
self.debug("invoke")
|
|
context.add_fileselect(self.__operator__)
|
|
return ('RUNNING_MODAL',) #self.exec(context)
|
|
|
|
def poll(self, context): # poll isnt working yet
|
|
self.debug("poll")
|
|
return True
|