Skip to content

Instantly share code, notes, and snippets.

@kojiokb
Created November 10, 2016 14:41
Show Gist options
  • Save kojiokb/ea78eff8c902ef955701c17ace0524a5 to your computer and use it in GitHub Desktop.
Save kojiokb/ea78eff8c902ef955701c17ace0524a5 to your computer and use it in GitHub Desktop.
BlenderのColor Gridを画像ファイルとして保存するスクリプト

Color Gridとは

動作確認環境

  • Windows 10 Home 64bit / macOS Sierra 10.12.1
  • Blender 2.78a 64bit

スクリプト

import bpy

image_name = "color_grid"
bpy.ops.image.new(name=image_name, width=4096, height=4096, color=(0.0, 0.0, 0.0, 1.0), alpha=False, generated_type='COLOR_GRID', float=False)
image = bpy.data.images[image_name]
image.filepath = "/Users/[ユーザー名]/Pictures/color_grid.png" #保存先を指定
image.save()
# 生成したimageを削除 (複数回実行する場合にimage_nameが重複するため)
image.user_clear() # user countを0にしないとremove()できないっぽい
bpy.data.images.remove(image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment