我正在学习这个教程:
https://docs.blender.org/manual/en/latest/advanced/scripting/addon_tutorial.html
我从教程中复制了下面的脚本,并且在运行时它能够编译成功,但是我无法在操作搜索菜单(F3
)中搜索到“Move X by One”来执行该操作,如何让该操作显示在搜索菜单中?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()