Reputation: 2471
I've only a short question. Currently I'm writing an addon for Blender. Everything works fine, but when I want to add the vertices and faces to the current Blender-Scene, I got the following error:
File "/usr/lib/blender/scripts/modules/bpy_types.py", line 378, in <listcomp>
vertices_flat = [f for v in vertices for f in v]
TypeError: 'numpy.float32' object is not iterable
EDIT: Here ist the code:
def add2Scene(self,verts):
print("Adding object to current scene")
triMesh = bpy.data.meshes.new("MCIsosurface")
triMesh.from_pydata(verts , [], self.faces)
triObj = bpy.data.objects.new("MCIsosurface", triMesh)
#triObj.setLocation(0,0,0)
bpy.context.scene.objects.link(triObj)
print("done")
Upvotes: 0
Views: 787
Reputation: 2471
I've solved the Problem
I stored the position like this: X Y Z X Y Z
Blender need the data like this
((XYZ),(XYZ))
so a simple reshape solved it:
verts = self.vertices.reshape(len(self.vertices)/3,3)
Upvotes: 2