import Blender as B # Take the vals: SC = B.Scene.GetCurrent() SCR = SC.getRenderingContext() ObjSelect = SC.objects.active origName = ObjSelect.name SizeX = SCR.sizeX SizeY = SCR.sizeY AspectX = float(SCR.aspectRatioX()) AspectY = float(SCR.aspectRatioY()) Aspect = AspectX / AspectY # WTF should I add here exactly? FrameA = B.Get('curframe') FrameP = B.Get('staframe') FrameF = B.Get('endframe') FrameRate = SCR.fps # Inicialazing Lists LocX,LocY,LocZ,RotX,RotY,RotZ = [],[],[],[],[],[] #----------------------------------------------------- # CREATING LISTS # Moves to the starting frame B.Set('curframe', FrameP) FrameA = FrameP while FrameA < (FrameF + 1): B.Set('curframe', FrameA) # Worldspace matrix mat= ObjSelect.mat LocX.append (mat.translationPart().x) LocZ.append (mat.translationPart().y) LocY.append (-mat.translationPart().z) RotX.append (mat.toEuler().x) RotZ.append (mat.toEuler().y) RotY.append (-mat.toEuler().z) FrameA += 1 #------------------------------------------------------- Range = FrameF-FrameP+1 # File writing starts HERE! File = open ('AfterEffectsExporter.txt','w') # The header File.write ('Adobe After Effects 7.0 Keyframe Data\n\n\ Units Per Second %i\n\ Source Width %i\n\ Source Height %i\n\ Source Pixel Aspect Ratio %.4f\n\ Comp Pixel Aspect Ratio %.4f\n\ '%(FrameRate, SizeX, SizeY, Aspect, Aspect)) # Loc and Rot values are writen in an entirely diferent way, how clever... # Write Loc values ----------------------------------- File.write ('\nTransform Position\n\ Frame X pixels Y pixels Z pixels') for i in range (Range): File.write ('\n %i %f %f %f ' % (i+1,LocX[i], LocY[i], LocZ[i])) # Write Rot values ----------------------------------- # Z values File.write('\n\nTransform Rotation\n Frame degrees') for i in range (Range): File.write('\n %i %f' % (i+1, RotZ[i])) # X values File.write('\n\nTransform X Rotation\n Frame degrees') for i in range (Range): File.write('\n %i %f' % (i+1, RotX[i])) # Y values File.write('\n\nTransform Y Rotation\n Frame degrees') for i in range (Range): File.write('\n %i %f' % (i+1, RotY[i])) # THE END ----------------------------------- File.write('\n\n\nEnd of Keyframe Data\n') B.Set('curframe', FrameP) # Back to starting Frame print "\nExporting Done!\nYour file is located in \ Blender's root folder, now send bug reports to ZanQdo"