I'm trying to create a Vector object (from mathutils library), whereby I have a csv file with 3 columns: x coordinate, y coordinate and z coordinate. All I want to do is import this CSV file in Blender and pass the x,y,z values to the
Vector object, using python script. This is my code so far:
import bpy import bmesh from mathutils import Vector, Matrix from itertools import product import random x_size = 512 y_size = 512 z_max = 256 csvfile = open(r'C:\Users\%username%\Desktop\Deep-lizard\x_y_z coor.csv') inFile = csv.reader(csvfile) # skip header inFile.__next__() vertices = [Vector( (float(r), float(r), float(r)) for r in inFile]
However, when I run this script I get the error:
File "C:\Users\%username%\Documents\new script.blend\Text", line 19 vertices = [Vector( (float(r), float(r), float(r)) for r in inFile] ^ SyntaxError: invalid syntax location: <unknown location>:-1 Python script failed, check the message in the system console
The csv file content is in this format:
Not sure where I'm going wrong. Any help is greatly appreciated.