Case: I'm exporting a list of coordinates from vertices (x, y, z-Coordinates) to a csv. file.

import bpy  
import os

main_path = os.getcwd()
print("writing to: " + main_path + "\n\n")

outputfile = 'G:\\final\\list_of_Vertices.csv'
with open(outputfile, 'w') as w_file:

for i in bpy.context.active_object.data.vertices:  
    print(i.co," ")  
    coords = i.co.x, i.co.y, i.co.z  
    w_file.write(str(coords)+" \n")  

So what I get is a csv file like this:

(-8.9578,-10.9873,6.8372) ...

When I try to use this file again to work with the coordinates blender gives me the error:

ValueError: could not convert string to float: '(-8.960794448852539'...).

My question:

How can I get rid of the braces so that I can use the generated csv file?

Thank you very much :)

  • $\begingroup$ Suggest this is more a python question than blender. write(",".join(map(str, coords)) $\endgroup$
    – batFINGER
    Aug 7, 2017 at 15:53
  • $\begingroup$ I'm voting to close this question as off-topic because it is primarily about python. $\endgroup$
    – batFINGER
    Aug 7, 2017 at 15:55


Your Answer

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

Browse other questions tagged or ask your own question.