0

我大约 30 分钟进入 Blender 的 python API 并且我一直在阅读文档。也许我看起来不够努力,但从我所看到的,我不能只是将一个对象(如 ico_sphere)分配给一个名为的变量Sphere,然后只用方法修改它的属性?

import bpy

bpy.ops.object.select_all(action="SELECT")
bpy.ops.object.delete()

Sphere = bpy.ops.mesh.primitive_ico_sphere_add(location=[0,0,0])

# Does something like this work?
Sphere.set_color('red')

我做了很多,matplotlib我想知道,如果 bpy 有类似的面向对象的接口?

4

1 回答 1

0

在搅拌机中,操作员返回一个状态,通常是{'FINISHED'}.

运行添加对象运算符后,新对象可以在bpy.context.object.

bpy.ops.mesh.primitive_ico_sphere_add(location=[0,0,0])
Sphere = bpy.context.object
Sphere.location = (1,2,3)
Sphere.active_material = bpy.data.materials.new('mymat')
Sphere.active_material.diffuse_color = (1,0,0,1)

请注意,基于节点的材质需要更多的工作。有一个特定于搅拌机的 SE 站点,您可以在其中找到一些脚本示例,例如

于 2019-10-06T04:28:37.503 回答