简体   繁体   English

搅拌器numpy.float32

[英]Blender numpy.float32

I've only a short question. 我只是一个简短的问题。 Currently I'm writing an addon for Blender. 目前,我正在为Blender编写插件。 Everything works fine, but when I want to add the vertices and faces to the current Blender-Scene, I got the following error: 一切正常,但是当我要将顶点和面添加到当前的Blender-Scene时,出现以下错误:

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: 编辑:这里ist代码:

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")

I've solved the Problem 我已经解决了问题

I stored the position like this: XYZXYZ 我这样存储位置:XYZXYZ

Blender need the data like this 搅拌机需要这样的数据

((XYZ),(XYZ)) ((XYZ),(XYZ))

so a simple reshape solved it: 所以一个简单的重塑就解决了:

verts = self.vertices.reshape(len(self.vertices)/3,3)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM