我正在完成本教程:https :
//docs.blender.org/manual/en/latest/advanced/scripting/addon_tutorial.html
我从教程中复制了下面的脚本,当我运行脚本时,它编译没有任何错误。我应该能够在操作员搜索菜单 ( F3) 中搜索“按一个移动 X”来执行操作员,但它没有显示在操作员搜索菜单中。如何让操作员显示在搜索菜单中?Blender 2.9 有什么变化吗?
bl_info = {
"name": "Move X Axis",
"category": "Object"
}
import bpy
class ObjectMoveX(bpy.types.Operator):
bl_idname = "object.move_x"
bl_label = "Move X by One"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
scene = context.scene
for obj in scene.objects:
obj.location.x += 1.0
return {'FINISHED'}
def register():
bpy.utils.register_class(ObjectMoveX)
def unregister():
bpy.utils.unregister_class(ObjectMoveX)
if __name__ == "__main__":
register()
Run Code Online (Sandbox Code Playgroud)