simple python export script question


(nicewon) #1

I am using Blender 2.25. And i am trying to write an export script for an animation to a file for a game i am making. The problem is none of the frames of my animation are being exported not even the 1st one. But it says that the frames are changing.

here is my code:

import Blender
f=open(‘run’,‘w’)

num_keyf = 15
num_frames = 30
#frame_num = Blender._Blender.Get(‘staframe’)
frame_num = 1
Blender._Blender.Set(‘curframe’,frame_num)
m = Blender.Mesh.get(‘man’)

numv = len(m.verts)
print ‘%2d’ % (frame_num)
print ‘%2d’ % (numv)
f.write(str(numv)+’
‘)
f.write(str(num_keyf)+’
‘)
f.write(str(num_frames)+’
')

while frame_num < num_frames:
Blender._Blender.Set(‘curframe’,frame_num)
m = Blender.Mesh.get(‘man’)
f.write(str(frame_num)+’
‘)
for x in m.verts:
#print x.co
f.write(str(x.co[0])+’ ‘)
f.write(str(x.co[1])+’ ‘)
f.write(str(x.co[2])+’
')
print Blender._Blender.Get(‘curframe’)
frame_num = frame_num + 2

f.close()

I would be greatful for any help

Keep it free
~Nicewon


(nicewon) #2

Here is the code that got it working bold lines are the major lines i was missing:

import Blender
f=open(‘run’,‘w’)
cs = Blender.Scene.getCurrent()
ob = cs.getChildren()[1]
num_keyf = 29
num_frames = 29

frame_num = 1
Blender._Blender.Set(‘curframe’,frame_num)
m = Blender._Blender.NMesh.GetRawFromObject(‘man’)
while frame_num < num_frames:
Blender._Blender.Set(‘curframe’,frame_num)
Blender.Redraw()
f.write(str(frame_num)+’
‘)
m = Blender._Blender.NMesh.GetRawFromObject(‘man’)
for x in m.verts:
f.write(str(x.co[0])+’ ‘)
f.write(str(x.co[1])+’ ‘)
f.write(str(x.co[2])+’
')
print Blender._Blender.Get(‘curframe’)
frame_num = frame_num + 1
f.close()

I hope this helps someone