I've created an importer for an obscure texture format and I can invoke it as an operator successfully. Because I'm chaining two addons together, (a model importer that also automatically imports textures), I really want to get the resultant image object from the texture import operator so that I can properly . However, because operators can only return success or failure codes (eg. {'FINISHED'}
), I can only really guess as to what the resultant image name might be.
The texture importer execute
function looks like this:
def execute(self, context):
dtx = DTX(self.filepath)
image_name = os.path.splitext(os.path.basename(self.filepath))[0]
image = bpy.data.images.new(image_name, dtx.width, dtx.height, alpha=True)
image.pixels[:] = dtx.pixels[:]
# I want to "return" the image to the caller, indirectly, somehow.
return {'FINISHED'}
The model import script calls the texture importer like so:
bpy.ops.io_lithtech.import_dtx(filepath=texture)
Is there a way to indirectly return anything from the execution of an operator?