self.vertices.foreach_set("co", vertices_flat)

Okay, I’ve built a string from a file for use with ‘from_pydata(Verts, Edges, Faces)’

I also have a variable in the script that is equal to exactly the output that I read, and manipulate from my file.

Variable >> [[0.5, 0.5, 0.5],[0.5, -0.5, 0.5],[-0.5, -0.5, 0.5],[-0.5, 0.5, 0.5]]
From file >> [[0.5, 0.5, 0.5],[0.5, -0.5, 0.5],[-0.5, -0.5, 0.5],[-0.5, 0.5, 0.5]]

The problem is when I use the from_pydata command using the variable, it works, but when I comment it out and use the built variable, I get a “self.vertices.foreach_set(“co”, vertices_flat)” error.

You say you build a string from the file? In that case that’s the error, verts should be lists of lists containing floats, not plain strings.

If you’re reading from a text file you need find a way to convert each vertex coordinate to a float, and append each float to a list (although it’s not necessary, see below). Storing the vertex coords with braces in the text file is not very convenient, usually they are all given one after the other.

Instead of from_pydata, you can build the vertex only to try your code:

Vertices = [0.5, 0.5, 0.5,0.5, -0.5, 0.5,-0.5, -0.5, 0.5,-0.5, 0.5, 0.5]
VertCount = len(Vertices)

me_ob  ="Test")
me_ob.vertices.foreach_set("co", Vertices)