PROBLEM:
Hello all. I am new to blender and need help. I have 2 objects (e.g 2 box mesh) I would like to export their properties as obj file in blender 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
CODE
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
Observation:
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. Please, how do I go about this?