phy_export/phy_export.py
josh 3d82e311cf Writing plane, cube, and sphere objects;
Including object name as first parameter;
Parameter order after name always size, location, rotation;

git-svn-id: svn://anubis/misc/phy_export@138 bd8a9e45-a331-0410-811e-c64571078777
2009-09-25 14:48:05 +00:00

34 lines
1.1 KiB
Python

#!BPY
"""
Name: 'Joshs Physics Information (.phy) Exporter'
Blender: 244
Group: 'Export'
Tooltip: 'Joshs Physics Information (.phy) Exporter'
"""
import Blender
import bpy
def write(filename):
out = file(filename, "w")
sce = bpy.data.scenes.active
for ob in sce.objects:
if ob.type == 'Mesh':
if len(ob.data.faces) == 1:
# found a plane
e = ob.getEuler()
out.write("plane \"%s\" %f %f %f %f %f %f\n" %
((ob.name,) + ob.getLocation() + (e[0], e[1], e[2])))
elif len(ob.data.faces) == 6:
# found a cube
e = ob.getEuler()
out.write("cube \"%s\" %f %f %f %f %f %f %f %f %f\n" %
((ob.name,) + ob.getSize() +
ob.getLocation() +
(e[0], e[1], e[2])))
elif len(ob.data.faces) >= 1024:
out.write("sphere \"%s\" %f %f %f %f\n" %
((ob.name, ob.SizeX) + ob.getLocation()))
Blender.Window.FileSelector(write, "Export")