PyAPI: allow subclasses of io_utils.ExportHelper to set when the extension is enforced.
This commit is contained in:
@@ -25,6 +25,10 @@ from bpy.props import StringProperty, BoolProperty
|
||||
class ExportHelper:
|
||||
filepath = StringProperty(name="File Path", description="Filepath used for exporting the file", maxlen=1024, default="", subtype='FILE_PATH')
|
||||
check_existing = BoolProperty(name="Check Existing", description="Check and warn on overwriting existing files", default=True, options={'HIDDEN'})
|
||||
|
||||
# subclasses can override with decorator
|
||||
# True == use ext, False == no ext, None == do nothing.
|
||||
check_extension = True
|
||||
|
||||
def invoke(self, context, event):
|
||||
import os
|
||||
@@ -41,12 +45,18 @@ class ExportHelper:
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
def check(self, context):
|
||||
filepath = bpy.path.ensure_ext(self.filepath, self.filename_ext)
|
||||
check_extension = self.check_extension
|
||||
|
||||
if check_extension is None:
|
||||
return False
|
||||
|
||||
filepath = bpy.path.ensure_ext(self.filepath, self.filename_ext if check_extension else "")
|
||||
|
||||
if filepath != self.filepath:
|
||||
self.filepath = filepath
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class ImportHelper:
|
||||
|
||||
Reference in New Issue
Block a user