illiyas
(illiyas)
September 22, 2010, 6:45am
1
Hi, I am new to blender scripting.
I had taken a default cube, i just want to color the cube using script.
import Blender
ob=Blender.Object.Get(‘Cube’)
please complete the coloring part of above code
and i just want to color the whole object not a single face
Thank you,
PKHG
(PKHG)
September 22, 2010, 7:41am
2
Forget old Blender (nearly)
Blender 2.54 SVN320050
Example make the default Cube ‘violet’ (ok …)
import bpy
mat = bpy.data.materials.new("PKHG")
mat.diffuse_color = (float(.5),0.0,1.0)
o = bpy.context.selected_objects[0]
o.active_material = mat
illiyas
(illiyas)
September 22, 2010, 9:14pm
3
i have objects like cube, cylinder and tube
i want to add colors to thee objects
import Blender
from Blender import *
scn = Blender.Scene.GetCurrent()
me=Mesh.Primitives.Cylinder()
outershealth=scn.objects.new(me)
i just want to color the above cylinder.
please help me.
PKHG
(PKHG)
September 23, 2010, 6:15am
4
Sorry, I would know only how to do THAT in the latest version of Blender.
mythcat
(mythcat)
September 23, 2010, 7:07am
5
Why this not working with specular ?
import bpy
mat = bpy.data.materials.new(“PKHG”)
mat.diffuse_color = (float(1.5),0.0,1.0)
mat.specular_color = (200.0,1.0,100.0)
o = bpy.context.selected_objects[0]
o.active_material = mat
PKHG
(PKHG)
September 23, 2010, 8:38am
6
Works in my Blender (2.54 W 32) … may get a newer version?!
Abidos
(Abidos)
September 23, 2010, 1:29pm
7
In 2.49b:
from Blender import *
ob = Object.Get("Cube")
me = ob.getData(mesh=1)
material = Material.New("matRose")
material.rgbCol = [0.8,0.6,0.6] # some rose color
ob.setMaterials([material])
ob.colbits = (1<<0)
me.materials = [material]
Redraw()
Not that I dont like Blender development but while asking “Why this or that python code is not working in 2.5x?” almost 90% of answers seems to be “Because API is unstable or still incomplete or you’re using another version.”
I wish this percentage be less than 5 !!!
Regards,
illiyas
(illiyas)
September 23, 2010, 9:37pm
8
Thanks bro… I got it what i want…