Skip to content

Instantly share code, notes, and snippets.

@nezuppo
Created March 10, 2019 12:19
Show Gist options
  • Save nezuppo/b593b9714abe2f7b2b5c095baf5c7f0b to your computer and use it in GitHub Desktop.
Save nezuppo/b593b9714abe2f7b2b5c095baf5c7f0b to your computer and use it in GitHub Desktop.
Blender でオブジェクトに色を付けてみた
import bpy
DEPTH = 10
def delete_all():
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(True)
def main():
# まずは全て削除
delete_all()
# 緑色のマテリアル作成
mat = bpy.data.materials.new(name='mat-color-1')
mat.diffuse_color = (0,1,0)
# 円柱を作成
bpy.ops.mesh.primitive_cylinder_add(
vertices=100, radius=10.0, depth=DEPTH, location=(0, 0, 0))
# 円柱に緑色のマテリアルを設定
bpy.context.object.data.materials.append(mat)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment