1

I want to make some operationi automatic.But I met some trouble in export the image after I bake it.At first I try to use "bpy.ops.object.bake_image()" to bake the image.But the result image can not be active in uv editor. The bake was success,but the result image didn't appear in the uv editor.It need selected so that I could export the file.

So I search the document , and found the other command "bpy.ops.object.bake()".It have a parameter "save_mode",but I still met some obstacle in using this command.It always point me out that " RuntimeError: error: No active image found in material "material" (0) for object "1.001" ". Here is the official document about this two command:
https://docs.blender.org/api/blender_python_api_2_78a_release/bpy.ops.object.html?highlight=bake#bpy.ops.object.bake

Can anyone try to give me some solution or some advice that how can I make this thing right.

RyanChen
  • 21
  • 3
  • Hers is the link that I try to automatic the operation :https://software.intel.com/en-us/blogs/2015/03/27/intel-realsense-3d-scanning-how-to-import-to-unity – RyanChen Feb 26 '17 at 14:45

1 Answers1

2

Many of blenders operators require a certain context to be right before they will work, for bpy.ops.image.save() that includes the UV/Image editor having an active image. While there are ways to override the current context to make them work, it can often be easier to use other methods.

The Image object can save() itself. If it is a new image you will first need to set it's filepath, you may also want to set it's file_format.

img = bpy.data.images['imagename']
img.filepath = '/path/to/save/imagename.png'
img.file_format = 'PNG'
img.save()
Community
  • 1
  • 1
sambler
  • 6,917
  • 1
  • 16
  • 23