I am working through this tutorial:
https://docs.blender.org/manual/en/latest/advanced/scripting/addon_tutorial.html
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()
A pop-up menu with access to all Blender tools is available by pressing F3 . Simply start typing the name of the tool you want to refine the list. When the list is sufficiently narrowed, LMB on the desired tool or navigate with Down and Up , activate it by pressing Return .
A blender operator is primarily in charge of operating and adjusting blending machines while adhering to guidelines and safety protocols.
As pointed out by other users, the API has been updated. You can see the release notes here:
Blender 2.90: Python API where it says:
...add-ons that expose operators only through search need to be updated.
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.
Add the menu_func
function:
def menu_func(self, context):
self.layout.operator(ObjectMoveX.bl_idname)
And update the register
function:
def register():
bpy.utils.register_class(ObjectMoveX)
bpy.types.VIEW3D_MT_object.append(menu_func)
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:
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.
Sybren aknowledged this in this post. The solution in my case was to copy this example. Here how it works:
bpy.types.TOPBAR_MT_app_system.append(menu_func)
menu_func(self, context)
with:
self.layout.operator(
your argument to register_class .bl_idname)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With