1

So I was trying use this script from reddit https://github.com/JaredTS486/Blender_Particles/blob/master/particles.py Then I encountered this problem where it says

bpy_struct : item.attr = val : 
 sequences of dimensions 0 should contain 4 items, not 3 

Here my code for material is

def makeMaterial(name, diffuse, specular, alpha):
    mat = bpy.data.materials.new(name)
    mat.diffuse_color = diffuse
    mat.diffuse_shader = 'LAMBERT' 
    mat.diffuse_intensity = 1.0 
    mat.specular_color = specular
    mat.specular_shader = 'COOKTORR'
    mat.specular_intensity = 0.5
    mat.alpha = alpha
    mat.ambient = 1
    return mat

red = makeMaterial('Red', (1,0,0), (1 ,1 ,1), 1) yellow = makeMaterial('Yellow',(1,1,0), (1 ,1 ,1), 1) blue = makeMaterial('Blue', (0,0,1), (1 ,1 ,1), 1) green = makeMaterial('Green', (0,1,0), (0.5,0.5,0), 0.5) white = makeMaterial('White', (1,1,1), (0.5,0.5,0), 0.5) black = makeMaterial('Black', (0,0,0), (0.5,0.5,0), 0.5)

What should I do?

batFINGER
  • 84,216
  • 10
  • 108
  • 233

1 Answers1

1

Re-jig the script for RGBA

The script was written in 2013 a time when the now defunct blender internal render material colors did not include the alpha channel, as demonstrated by a simple test in python console

>>> D.materials['Material'].diffuse_color[:]
(0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0)

This is what the error is telling you. In case above for diffuse_material property of material has 4 elements not 3.

Edit, and test in python console to suit current status.

Somewhat related Pixel to voxel in Blender 2.92

Note. Will run into more errors, once again testing in the python console using TAB to auto complete, will show that the specular_shader option is also a thing of the past.

>>> D.materials['Material'].specular_
                                     color
                                     intensity

(Alternatively use a pre 2.8 version of blender)

batFINGER
  • 84,216
  • 10
  • 108
  • 233