I am having a really hard time trying to create a diffuse colored plane by script. The contours of the plane I do get right, but I can't seem to get the surface filled.
g_d = bpy.data.meshes.new(name="GroundM") g_o = bpy.data.objects.new(name="GroundO", object_data = g_d) scene.objects.link(g_o) g_o.location = (0,0,0) g_o.select = True scene.objects.active = g_o # Fill in the data for the mesh b = 10 v1 = (-b,b,0) v2 = (b,b,0) v3 = (b,-b,0) v4 = (-b,-b,0) verts = [v1, v2, v3, v4] g_d.vertices.add(4) g_d.edges.add(4) g_d.faces.add(1) g_d.vertices.co = (-b,b,0) g_d.vertices.co = (b,b,0) g_d.vertices.co = (b,-b,0) g_d.vertices.co = (-b,-b,0) g_d.edges.vertices = (0,1) g_d.edges.vertices = (1,2) g_d.edges.vertices = (2,3) g_d.edges.vertices = (3,0) g_d.faces.vertices = (0,1,2,3)
As a result I get the edges of a square, and an error message "Mesh object has no attribute "faces"." But one should be able to define faces in a mesh..