Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions imagepaste/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
import bpy


# override the api
def bpy_ops_import_image_to_plane(*args, **kwargs):
if bpy.app.version[0] < 4 or (bpy.app.version[0] == 4 and bpy.app.version[1] < 2):
return bpy.ops.import_image.to_plane(*args, **kwargs)
# the latest api
return bpy.ops.image.import_as_mesh_planes(*args, **kwargs)

def bpy_ops_object_load_reference_image(*args, **kwargs):
if bpy.app.version[0] < 4 or (bpy.app.version[0] == 4 and bpy.app.version[1] < 2):
return bpy.ops.object.load_reference_image(*args, **kwargs)
# the latest api
return bpy.ops.object.empty_image_add(*args, **kwargs)


class IMAGEPASTE_OT_imageeditor_copy(bpy.types.Operator):
"""Copy image to the clipboard"""

Expand Down Expand Up @@ -158,7 +172,7 @@ def execute(self, _context):
if clipboard.report.type != "INFO":
return {"CANCELLED"}
for image in clipboard.images:
bpy.ops.import_image.to_plane(files=[{"name": image.filepath}])
bpy_ops_import_image_to_plane(files=[{"name": image.filepath}])
return {"FINISHED"}

@classmethod
Expand All @@ -185,7 +199,7 @@ def execute(self, _context):
if clipboard.report.type != "INFO":
return {"CANCELLED"}
for image in clipboard.images:
bpy.ops.object.load_reference_image(filepath=image.filepath)
bpy_ops_object_load_reference_image(filepath=image.filepath)
return {"FINISHED"}

@classmethod
Expand Down
3 changes: 2 additions & 1 deletion imagepaste/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ def view3d_paste_reference_imageaddmenu_draw(self, _context):
@bpy.app.handlers.persistent
def move_to_save_directory_handler(_self, _context):
"""Handler to move the images to the save directory after the file is saved."""
bpy.ops.imagepaste.move_to_save_directory("INVOKE_DEFAULT")
if bpy.ops.imagepaste.move_to_save_directory.poll():
bpy.ops.imagepaste.move_to_save_directory("INVOKE_DEFAULT")


addon_keymaps = []
Expand Down