With the default cube mesh and Blender 2.77, if I run this code in console:
for f in bpy.data.meshes['Cube'].polygons:
for v in f.vertices:
print("%f %f %f" % bpy.data.meshes['Cube'].vertices[v].co[:])
print("%f %f %f" % f.normal[:])
print("\n")
I get the following output (truncated for brevity):
-1.000000 -1.000000 1.000000
-1.000000 0.000000 0.000000
-1.000000 1.000000 1.000000
-1.000000 0.000000 0.000000
-1.000000 1.000000 -1.000000
-1.000000 0.000000 0.000000
-1.000000 -1.000000 -1.000000
-1.000000 0.000000 0.000000
-1.000000 1.000000 1.000000
0.000000 1.000000 -0.000000
...
However, with this:
for f in bpy.data.meshes['Cube'].polygons:
for v in f.vertices:
print("%f %f %f %f %f %f\n" % bpy.data.meshes['Cube'].vertices[v].co[:], f.normal[:])
print("\n")
or even this:
for f in bpy.data.meshes['Cube'].polygons:
for v in f.vertices:
print("%f %f %f %f %f %f" % bpy.data.meshes['Cube'].vertices[v].co[0], py.data.meshes['Cube'].vertices[v].co[1], py.data.meshes['Cube'].vertices[v].co[2], f.normal[0], f.normal[1], f.normal[2])
print("\n")
I get the error:
Traceback (most recent call last):
File "<blender_console>", line 3, in <module>
TypeError: not enough arguments for format string
Why can I print 3 floats easily but printing 6 floats doesn't work? Is Python's formatted printing different that C's (in this respect)? Or is it something Blender specific? Is there a maximum limit on how many 'arguments' the format string can take?
print(str, end=",")
for example. Something likecube = bpy.data.meshes.get("Cube")
and forv in cube.vertices:
would make the code a whole lot more readable... and also I vote to close this q as it is not really about blender python or the console, rather a syntax error. $\endgroup$ – batFINGER Sep 4 '16 at 7:59