Hey there everyone.
A while ago i worked on a script to export locations, rotations & the scale of objects to a .txt file so i can use Blender as a placement editor for game creation. I have just run into a problem with the rotations being written out as radians as apposed to the degrees shown in the “transform properties” window.
Anyone know how to write out the information to degrees?
Here is the original script.
bl_info = {
"name": "Object Location, Scale, Rotation & Custom Properties",
"author": "Robert Hogg",
"blender": (2,69,0),
"version": (0,0,1),
"location": "File > Import-Export",
"description": "Object Location, Scale, Rotation & Custom Properties.",
"category": "Import-Export"}
import bpy
from bpy_extras.io_utils import ExportHelper
class ExportMyFormat(bpy.types.Operator, ExportHelper):
bl_idname = "export_my_format1.txt";
bl_label = "Export .Txt";
bl_options = {'PRESET'};
filename_ext = ".txt";
filepath = bpy.props.StringProperty("FILE_PATH")
global a
def execute(self, context):
file = open(self.filepath,'w')
file.write('[start]')
file.write("
")
for a in bpy.context.selected_objects:
file.write('Object:'+a.name)
file.write("
")
file.write('X#:'+str(a.location[0]))
file.write("
")
file.write('Y#:'+str(a.location[2]))
file.write("
")
file.write('Z#:'+str(a.location[1]))
file.write("
")
file.write('Xrot#:'+str(a.rotation_euler[0]))
file.write("
")
file.write('Yrot#:'+str(a.rotation_euler[2]))
file.write("
")
file.write('Zrot#:'+str(a.rotation_euler[1]))
file.write("
")
file.write('Xsc#:'+str(a.scale[0]))
file.write("
")
file.write('Ysc#:'+str(a.scale[2]))
file.write("
")
file.write('Zsc#:'+str(a.scale[1]))
file.write("
")
objname = a.name
ob = bpy.data.objects[objname]
for e in ob.event_settings:
file.write("%s=%s
" % (e.event_field, e.event_value))
file.write('[next]')
file.write("
")
file.write('[end]')
return {'FINISHED'};
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
def menu_func(self, context):
self.layout.operator(ExportMyFormat.bl_idname, text="My Model Format1(.txt)");
def register():
bpy.utils.register_module(__name__);
bpy.types.INFO_MT_file_export.append(menu_func);
def unregister():
bpy.utils.unregister_module(__name__);
bpy.types.INFO_MT_file_export.remove(menu_func);
if __name__ == "__main__":
register()