我想以编程方式在Blender中创建一个3D模型
类似于:

createcube(loc,axis)

我该怎么做?(使用Python?,如何?)
(我想用这个来创建三维分形)

最佳答案

对。Python是Blender的内置语言。在Blender UI上所能做的一切都可以用python代码完成。
下面是一些创建网格的示例代码:

#----------------------------------------------------------
# File meshes.py
#----------------------------------------------------------
import bpy

def createMesh(name, origin, verts, edges, faces):
    # Create mesh and object
    me = bpy.data.meshes.new(name+'Mesh')
    ob = bpy.data.objects.new(name, me)
    ob.location = origin
    ob.show_name = True
    # Link object to scene
    bpy.context.scene.objects.link(ob)

    # Create mesh from given verts, edges, faces. Either edges or
    # faces should be [], or you ask for problems
    me.from_pydata(verts, edges, faces)

    # Update mesh with new data
    me.update(calc_edges=True)
    return ob

def run(origin):
    (x,y,z) = (0.707107, 0.258819, 0.965926)
    verts1 = ((x,x,-1), (x,-x,-1), (-x,-x,-1), (-x,x,-1), (0,0,1))
    faces1 = ((1,0,4), (4,2,1), (4,3,2), (4,0,3), (0,1,2,3))
    ob1 = createMesh('Solid', origin, verts1, [], faces1)
    verts2 = ((x,x,0), (y,-z,0), (-z,y,0))
    edges2 = ((1,0), (1,2), (2,0))
    ob2 = createMesh('Edgy', origin, verts2, edges2, [])

    # Move second object out of the way
    ob1.select = False
    ob2.select = True
    bpy.ops.transform.translate(value=(0,2,0))
    return

if __name__ == "__main__":
    run((0,0,0))

从这里复制:
http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets/Meshes
去这个链接看看你是否找到了你想要解决的问题。

关于python - 在Blender中以编程方式创建模型,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15150760/

10-14 18:00