importbpydefmyActivator(objName):# Pass bpy.data.objects datablock to scene classbpy.context.scene.objects.active = bpy.data.objects[objName]# Activate the object named 'Sphere'myActivator('Sphere')# Verify the 'Sphere' was activatedprint("Active object:", bpy.context.object.name)# Selected ...
Python 交互式控制台:定制的 Python 控制台对于浏览 Blender API 和探索 Python Blender 对象提供给我们的所有字段和方法非常有用;除了基本的 Python 内置插件,这个控制台还加载了 Blender 的内置插件和一些方便的变量,以便轻松访问 Blender API 的常用子模块 信息面板:一 开始可能看起来很奇怪,但这个面板只是调试你所...
pip install imagepip install imathsudo apt-get install libopenexr-dev zlib1g-dev # 安装依赖pip install openexr 编写脚本 脚本一:采集深度图 控制Blender采集深度图。 脚本执行命令: blender -b -P render_depth.py # 注意:终端执行即可,这个py文件不...
bpy.data.objects[candidates_name[i]].hide_render = False #objects must be renderable to export render image bpy.context.scene.objects.active = bpy.data.objects[candidates_name[i]] #get object bpy.ops.object.modifier_add(type='PARTICLE_SYSTEM') #add modifier as particle_system ...
API 本身,bpy(代表“Blender Python”),可以在 Blender 的特定文档中浏览;它被细分为几个子模块,其中 3 个最重要/最常用的是: bpy.context:它包含只读值的 getter 和 reader,这些值描述你当前的工作上下文,甚至是当前正在访问的区域(即窗口中的面板) ...
# update mesh data and free bmeshbmesh.update_edit_mesh(bunny_weave.data)bm.free()bpy.ops.object.mode_set(mode='OBJECT')# add a new materialmat=bpy.data.materials.new('material')bunny_weave.data.materials.append(mat)mat.use_nodes=Trueshader_Principled_BSDF=mat.node_tree.nodes.get('...
# Apply theobject's world matrix to the vertex's local coordinates togetworld coordinates vcoord=placement_ob.matrix_world @ vert.co # Set the render filepathforthe current vertex render.filepath=render_path.format(index) # Move the camera to the vertex's world positioncamera_ob.location =...
插件只是一个带有一些附加要求的Python模块,因此Blender可以在包含有用信息的列表中显示它。 举个例子,这是最简单的插件: bl_info = {"name": "My Test Add-on", "category": "Object"} def register(): print("Hello World") def unregister(): ...
# rename the object bpy.context.object.name = obj_name # return the object reference return bpy.context.object N_PLANETS = 6 for n in range(N_PLANETS): # get a random radius (a float in [1, 5]) r = 1 + random() * 4 # get a random distace to the origin point: # - an ...
filessketch_obj=import_obj(obj_path)mesh_obj=import_ply(ply_path)# Rotate the mesh object by 90 degrees around the X axisrotate_object(mesh_obj)# Convert the sketch object to a meshconvert_to_mesh(sketch_obj)# Export all objects to GLBexport_to_glb(glb_path)if__name__=="__main__...