On 09/08/2019 15:13, Paul St George wrote:
In the code (below) I want a new line like this:
Plane rotation X: 0.0
Plane rotation Y: 0.0
Plane rotation Z: 0.0
But not like this:
Plane rotation X:
0.0
Plane rotation Y:
0.0
Plane rotation Z:
0.0
Is it possible?
(I am using Python 3.5 within Blender.)
#
import os
outstream = open(os.path.splitext(bpy.data.filepath)[0] + ".txt",'w')
print(
"Plane rotation X:",bpy.data.objects["Plane"].rotation_euler[0],
"Plane rotation Y:",bpy.data.objects["Plane"].rotation_euler[1],
"Plane rotation Z:",bpy.data.objects["Plane"].rotation_euler[2],
file=outstream, sep="\n"
)
outstream.close()
The 'sep="\n"' parameter to print() means "put a newline between each
item." So don't do that. Put the newlines you do want in explicitly,
or use separate calls to print():
(I'm abbreviating because I really can't be bothered to type that much :-)
print("X:", thing[0],
"\nY:", thing[1],
"\nZ:", thing[2],
file=outstream)
or
print("X:", thing[0], file=outstream)
print("Y:", thing[1], file=outstream)
print("Z:", thing[2], file=outstream)
I would probably use the latter, but it's just a matter of personal
preference.
(Actually I would probably use outstream.write() and do my own
formatting, but let's not get side-tracked ;-)
--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list