Surely this has been asked before?
Rather than spending any more time searching for the elusive dupe, to the export part, I'm sure it's out there
Here is an example using f-string formatting.
import bpy
context = bpy.context
def sfmt(s):
return f"{s :10s}"
def vfmt(vec):
return ", ".join(f"{v : 10.4f}" for v in vec)
for obj in sorted(context.selected_objects, key=lambda o: o.name):
output = ",".join((
sfmt(obj.name),
vfmt(obj.location),
vfmt(obj.rotation_euler),
))
print(output)
Output of default scene, remember rotations are in radians.
Camera , 7.4811, -6.5076, 5.3437, 1.1093, 0.0000, 0.8149
Cube , 0.0000, 0.0000, 0.0000, 0.0000, -0.0000, 0.0000
Lamp , 4.0762, 1.0055, 5.9039, 0.6503, 0.0552, 1.8664
A number of other csv related questions.
How to read a csv file and use the values as x and y points in blender?
Massive import with CSV file
Moving and rotating using CSV
Generate and edit csv-file to reimport and use it with blender
How do I move an object using a csv file?
How to import a 3d object by csv file
csv file reading
Exporting coordinates of vertices to CSV
Import coordinates from CSV and create sphere at each position
some_string_var = ', '.join([str(x) for x in obj.rotation_euler])to get the rotation values separated by commas as a string. – Martynas Žiemys Dec 19 '19 at 13:02