在F3运算符搜索(Blender 2.9)中找不到自定义Blender运算符 [英] Unable to find custom Blender operator in F3 operator search (Blender 2.9)

查看:345
本文介绍了在F3运算符搜索(Blender 2.9)中找不到自定义Blender运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在完成本教程:
https://docs.blender.org/manual/en/Latest/advanced/scripting/addon_tutorial.html

我已经从教程中复制了以下脚本,并且在运行脚本时它可以毫无错误地进行编译.我应该能够搜索移动X一次"在操作员搜索菜单( F3 )中执行操作员,但是它没有显示在操作员搜索菜单中.如何让操作员出现在搜索菜单中?Blender 2.9中有什么变化吗?

I have copied the script below from the tutorial and it compiles without any errors when I run the script. I should be able to search "Move X by One" in the operator search menu (F3) to execute the operator, but it does not show up in the operator search menu. How can I get the operator to show up in the search menu? Has something changed in 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()

推荐答案

搅拌器2.90.1

其他用户指出,该API已更新.您可以在此处查看发行说明:
Blender 2.90:Python API 其中表示:

...仅通过搜索公开运算符的附件需要更新.

...add-ons that expose operators only through search need to be updated.

这是由于新增了操作员搜索功能,该操作员搜索功能仅通过菜单(通过 F3 访问)进行搜索.因此,您需要将运算符添加到菜单中.

This is due to the new addition of the operator search that only searches through menus (accessed by F3). Because of this, you need to add the operator to a menu.

添加 menu_func 函数:

def menu_func(self, context):
    self.layout.operator(ObjectMoveX.bl_idname)

并更新 register 函数:

def register():
    bpy.utils.register_class(ObjectMoveX)
    bpy.types.VIEW3D_MT_object.append(menu_func)

您现在可以通过操作员搜索( F3 )或通过菜单,即 Object> YourOperatorName

You can now either access your operator via the operator search (F3) or through the menus, i.e. Object>YourOperatorName

如果您不希望通过这些菜单访问这些内容,则发行说明中还会提及:

If you do not want these to be accessible via these menus, the release notes also mention:

对于例如主要面向开发人员的更晦涩的运算符,我们建议将它们添加到TOPBAR_MT_app_system菜单中.可通过顶部栏中Blender图标下的系统"菜单访问此文件.

For more obscure operators that are for example intended mainly for developers, we recommend adding them in the TOPBAR_MT_app_system menu. This is accessible through the System menu under the Blender icon in the top bar.

这篇关于在F3运算符搜索(Blender 2.9)中找不到自定义Blender运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆