Search This Blog

Showing posts with label add material. Show all posts
Showing posts with label add material. Show all posts

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)

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

Thursday 11 March 2021

TO COPY NODE TREE FROM ONE OBJECT TO ANOTHER.


Assume that you you have made a node tree to set up a new material for an object(Let us say an UV Sphere). Now you add  another object (let us say a Cube). To copy the node tree from UVSphere to the Cube follow these simple steps:


1. Select the UVSphere. In the node editor set up a simple material node tree and save it. Now select all the nodes using Box select option. To copy these node tree to clip board click on the first floppy disk (like icon in light yellow color on the menu bar of the node editor.


2. Select the Cube,click on new material and click on new. You will see a Diffuse BSDF node connected to the Material Output node.Click inside the node editor window using LMB. Now click on the floppy disk icon on the right side. The node tree of the UVSphere will be pasted here. Select the 3D window  and press Shift+Z to see the rendered view of both objects with the new material. Change in material setting of the nodes of UVSphere does not affect the material settings of the Cube.

Thursday 29 October 2020

BPY SCRIPT TO ADD A CUBE AND A MATERIAL TO IT

The following script can be used  to add  a cube and a material to it:

 

import bpy

bpy.ops.mesh.primitive_cube_add(location=(0,0,0))
obj_matl=bpy.data.materials.new("obj_clr")
obj_matl.diffuse_color=(1,0,0)
mesh=bpy.context.object.data
mesh.materials.append(obj_matl)

TO MIRROR ARMATURE BONES ON X AXIS 1. Assume that we are making a human rig in standing position. 2. Set the view to front view. 3. Create t...