Hy ! My name is Fanny. I am in Highschool and I have a project to do in Python (to make next week). So my project is to build a Rubik’s Cube with Python. My problem is to color the cubes : I want to name all the cube and after, to color cube’s faces, one by one, with Python. And I don’t know how to do this.
Thank you for your help. Sorry if there are faults, I’m French.
I hope that someone find a solution.
Thank you, Fanny
essaye celui ci ca devait fonctionner
PM s’ il y a un problem
add mat nodes
def matnew1 (r2, g2, b2, nameob , delloc):
r1 = 1.0
g1 = 0.0
b1 = 0.0
r1 = r2
g1 = g2
b1 = b2
matname1 = nameob
Create a new material for cycles Engine.
bpy.context.scene.render.engine = 'CYCLES'
flagmat = False # Mat exist
for item in bpy.data.materials:
if item.name == matname1: # Don't add mat if it already exist in mat list
print()
print (' mat exist in mat list')
flagmat = True
if flagmat: # Mat exist so assign mat to new ob !
if bpy.context.mode != 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')
material = bpy.data.materials.get(matname1)
bpy.ops.mesh.primitive_cube_add() # Add cube
bpy.context.object.data.materials.append(material) # New mat
obj_act = bpy.context.active_object
obj_act.location.x+= delloc
print ('act ob =',obj_act.name, ' del loc =', delloc )
# top.location = (0,2,5)
newcol = ( r1 , g1 , b1 )
bpy.context.object.active_material.diffuse_color = newcol # Object viewport color
print ('obj_act loc =', obj_act.location)
happy cl