Created
March 24, 2013 01:42
-
-
Save enzyme69/5230081 to your computer and use it in GitHub Desktop.
Blender Sushi script that gives random Vertex Color Layer set to selected meshes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import random | |
# Get selected objects | |
selected_meshes = bpy.context.selected_objects | |
# Add Materials that respects the Vertex Color for | |
# each selected and active objects | |
for mesh in selected_meshes: | |
mat = bpy.data.materials.new('VertexMat') | |
mat.use_vertex_color_paint = True | |
mat.use_vertex_color_light = True | |
mesh.data.materials.append(mat) | |
# Tell Blender to Update the Material | |
bpy.data.materials.is_updated = True | |
for mesh in selected_meshes: | |
# Create Vertex Color for each selected meshes | |
# bpy.context.selected_objects[0].data.vertex_colors | |
mesh.data.vertex_colors.new() | |
# Get Total Length of Vertex Colors for each selected meshes | |
# len(bpy.context.selected_objects[0].data.vertex_colors[0].data) | |
totalVertCol = len(mesh.data.vertex_colors[0].data) | |
# Iterate over every mesh vertex color and give it a single colour | |
colR = random.random() | |
colG = random.random() | |
colB = random.random() | |
for i in range(totalVertCol): | |
mesh.data.vertex_colors[0].data[i].color = colR, colG, colB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment