0
0

BlenderのバージョンによるPythonからの頂点カラーレイヤーの追加方法の違い

Last updated at Posted at 2024-08-20

概要

BlenderのPythonスクリプトから頂点カラーレイヤーを追加する場合、
Blender3.3以前では bpy.ops.mesh.vertex_color_add() と記述し、
Blender3.4以降では Mesh.data.vertex_colors.new() と記述します

Blender 3.3以前

import bpy

Mesh = bpy.context.view_layer.objects.active    # 選択されているメッシュを取得

# メッシュに頂点カラーレイヤーが無かったら追加する
if not Mesh.data.vertex_colors:
    bpy.ops.mesh.vertex_color_add()             # ★Blender3.3以前の頂点カラーレイヤー追加方法

Blender 3.4以降

import bpy

Mesh = bpy.context.view_layer.objects.active    # 選択されているメッシュを取得

# メッシュに頂点カラーレイヤーが無かったら追加する
if not Mesh.data.vertex_colors:
    Mesh.data.vertex_colors.new()               # ★Blender3.4以降の頂点カラーレイヤー追加方法
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0