Search This Blog

Monday, 20 December 2021

BPY SCRIPT TO ADD MATERIAL TO AN EXISTING OBJECT.

To run this script open blender, add a cube object and select it.Copy and paste these codes into you text editor and run it to add a material to the cube. Here Red material(color) is added to the Cube.

-------------------------------------------------------------------------------------------------------------------------------

 import bpy

mat_red=bpy.data.materials.new("red")

mat_red.diffuse_color=(0.8, 0, 0)

mesh=bpy.context.object.data

mesh.materials.clear()

mesh.materials.append(mat_red)

-------------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Please send your comment as to what extent these topics are explained clearly. If you want any new topic explained, just put up a message in the comment, we shall address it.

TO SET UNIT OF MEASUREMENT - METRIC/IMPERIAL

Instruction as applicable to Blender Version  3.00 and above.  In Blender, we can set the dimensions of Rotation, Length, Mass, Time and Tem...