Is it possible to export a text file containing the information of models placed in a scene such as Location, Size, and Rotation?

So if I had two cubes, it'd make a text file with something along the lines of

Location: X:11 Y:30 Z:20 Scale: X:40 Y:20 Z: 15 Rotation: X:15 Y:123 Z: 180, 
Location: X:18 Y:20 Z:10 Scale: X:20 Y:40 Z: 30 Rotation: X:20 Y:140 Z: 90

for both of the cubes in the scene.

  • 1
    $\begingroup$ yes it is possible, but what have tried till now $\endgroup$ – Chebhou Feb 16 '16 at 18:31
  • $\begingroup$ see str.format $\endgroup$ – pink vertex Feb 16 '16 at 20:26

this script work for all the mesh in the scene and save the data.txt in the same path as you blend file is save..... If you don't save the blend file the script don't work


    import bpy

def grados(radianes):
    x= (180*radianes)/3.141516
    return x

#open path_file where I will save
full_filel = bpy.data.filepath.split("\\")
contador = 1 
path_file = full_filel[0]

while contador != len(full_filel)-1:
    path_file = str(path_file) + "\\" + str(full_filel[contador])
    contador +=1

#path_file actual

#file name

file_name = "data.txt"

#path blend file
file1 = open((path_file + '\\' + file_name), 'w', encoding = "utf-8")

objects = bpy.context.scene.objects

for ob in objects:
    if ob.type =="MESH":
        name = ob.name
        loc = tuple(ob.location)
        sc = tuple(ob.scale)
        rot = [grados(ob.rotation_euler[0]), grados(ob.rotation_euler[1]), grados(ob.rotation_euler[2])]

        #print(name, " ", loc, " ", sc, " ", rot)

        dato = (ob.name," Location: ", loc, " Scale: ", sc, " Rotation: ", rot )
        #write data in file
        file1.write(str(dato) + "\n")

#close the file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.