Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created August 17, 2015 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/f237f3885159911c41f2 to your computer and use it in GitHub Desktop.
Save zeffii/f237f3885159911c41f2 to your computer and use it in GitHub Desktop.
import bpy
def pack_frame_info(idx):
f = bpy.context.scene.frame_current
dp_str = []
dp_str.append(str(f))
for obj in bpy.data.objects:
if not (tuple(True if i==idx else False for i in range(20)) == obj.layers[:]):
continue
mat = obj.matrix_world
loc = mat.to_translation()
rot = mat.to_3x3().to_quaternion()
scale = obj.dimensions
apt = {
'obj': obj.name,
'qtX': round(rot.x,3),
'qtY': round(rot.y,3),
'qtZ': round(rot.z,3),
'qtW': round(rot.w,3),
'loX': round(loc.x,3),
'loY': round(loc.y,3),
'loZ': round(loc.z,3),
'scX': round(scale.x,3),
'scY': round(scale.y,3),
'scZ': round(scale.z,3)
}
j = '{obj} {loX} {loY} {loZ} {qtX} {qtY} {qtZ} {qtW} {scX} {scY} {scZ}'.format(**apt)
dp_str.append(j)
return ','.join(dp_str)
k = pack_frame_info(3)
print(k)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment