2017-02-26 76 views
1

我想使某些操作自動化。但是我在烘烤後導出圖像遇到了一些麻煩。首先嚐試使用「bpy.ops.object.bake_image ()「來烘烤圖像,但結果圖像不能在uv編輯器中激活。 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.如何使用python導出烘焙圖像形式的攪拌機

所以我搜索文檔,並發現其他命令「bpy.ops.object.bake()」,它有一個參數「save_mode」,但我還是一直在使用這種command.It遇到了一些障礙指出我「RuntimeError:錯誤:在材質」材質「(0)中找不到對象」1.001「中的活動圖像」「。 下面是關於這個兩個命令的正式文件:
https://docs.blender.org/api/blender_python_api_2_78a_release/bpy.ops.object.html?highlight=bake#bpy.ops.object.bake

任何人都可以嘗試給我一些解決方案或一些建議,我怎麼能做出這件事情吧。

+0

Hers是我嘗試自動操作的鏈接:https://software.intel.com/zh-cn/blogs/2015/03/27/intel-realsense-3d-scanning-how- to-import-to-unity – RyanChen

回答

0

許多攪拌機操作員需要一定的環境才能工作,bpy.ops.image.save()包括具有活動圖像的UV /圖像編輯器。雖然there are waysoverride the current context爲使它們工作,但使用其他方法通常會更容易。

Image對象本身可以是save()。如果是新圖片,您首先需要將其設置爲filepath,您可能還需要將其設置爲file_format

img = bpy.data.images['imagename'] 
img.filepath = '/path/to/save/imagename.png' 
img.file_format = 'PNG' 
img.save() 
+0

謝謝!這是工作! – RyanChen