New optional operator function, check(), it takes the same arguments as execute().
This runs after changing a property and allows correcting incompatible options. Returning True will redraw the UI. Currently this is used for setting the write extension when saving files, so changing the image format also corrects the extension. The same is accessible from python where its used when saving SVG/EPS/PNG files. This fixes: [#23828] obj export problems, [#23760] Exporting OBJ and filetype ending also fixed document submission operator. Now the filename in the file selector is the one used for writing this means we remove the "Save Over" popup which could be overlooked too easily. Instead display the filename field with red tint, and a note in the tooltip.
This commit is contained in:
		| @@ -34,6 +34,14 @@ class ExportHelper: | ||||
|         context.window_manager.add_fileselect(self) | ||||
|         return {'RUNNING_MODAL'} | ||||
|  | ||||
|     def check(self, context): | ||||
|         filepath = bpy.path.ensure_ext(self.filepath, self.filename_ext) | ||||
|         if filepath != self.filepath: | ||||
|             self.filepath = filepath | ||||
|             return True | ||||
|         else: | ||||
|             return False | ||||
|  | ||||
|  | ||||
| class ImportHelper: | ||||
|     filepath = StringProperty(name="File Path", description="Filepath used for importing the file", maxlen=1024, default="", subtype='FILE_PATH') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user