0

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")
1
  • Can you paste more of the trace, so we can see the point in your code when it fails? Commented Jun 29, 2012 at 16:19

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.