I am new to Blender. I have 2 objects (e.g 2 box mesh) I would like to export their properties as obj file using python scripting. I would like to export the vertex of both objects firstly, followed by their faces. This is the code I am using below
import bpy
obj = list(bpy.data.objects)
print("Cube\n")
for a in obj:
mesh =a.data
for v in mesh.vertices:
#random output compared to what we have in the original file
print("v %.4f %.4f %.4f\n" % v.co[:]) #x,y,z coordinates
print("\n # 8 vertices\n")
for a in obj:
mesh =a.data
print( "g " +a.name+ "\n")
for p in mesh.polygons:
print("f")
for i in p.vertices:
print(" %d" % (i + 1))
print( "\n")
OUTPUT
g.cube 1
f 1 2 4 3
f 3 4 8 7
f 7 8 6 5
f 5 6 2 1
f 3 7 5 1
f 8 4 2 6
g Cube.002
f 1 2 4 3
f 3 4 8 7
f 7 8 6 5
f 5 6 2 1
f 3 7 5 1
f 8 4 2 6
Both faces of both objects are the same. This is not what I want. I would like the faces of the second object to start from 9 and so on.
How do I go about this?
for a in obj:
loop, which will be incremented after bylen(mesh.vertices)
for each successive object. As I said you might skip some vertices, but not knowing more about your end goal it's hard to give more precise information $\endgroup$