Tutorial addon sample (Move X by One) doesn't get executed and/or added as available voice when installed. #87180

Closed
opened 2021-04-03 22:18:05 +02:00 by Andrea Leganza · 7 comments

System Information
Operating system: Mac OS 10.15.7 (19H114) Catalina
Graphics card: ATI Radeon Vega

Blender Version
Broken: (example: 2.92, 02948a2cab44, master)
Worked: dunno

Running the script inside the Scripting editor doesn't do anything (2021-04-03 22.04.48.gif).

I tried also to install as an addon (Preferences->Addons->Install) it adds the voice to add-ons and let to enable it but it 2021-04-03 22.15.27.gif won't add the option in the editor, so searching as reported in the tutorial doesn't work.

There is no syntax error reported (tried also running form terminal the app to check if there were some error reported).

Code copied from https://docs.blender.org/manual/en/latest/advanced/scripting/addon_tutorial.html:

bl_info = {
    "name": "Move X Axis",
    "blender": (2, 80, 0),
    "category": "Object"
    }

import bpy
from bpy import context

class ObjectMoveX(bpy.types.Operator):
    """My Object Moving Script"""      # Use this as a tooltip for menu items and buttons.
    bl_idname = "object.move_x"        # Unique identifier for buttons and menu items to reference.
    bl_label = "Move X by One"         # Display name in the interface.
    bl_options = {'REGISTER', 'UNDO'}  # Enable undo for the operator.

    def execute(self, context):        # execute() is called when running the operator.

        # The original script
        scene = bpy.context.scene
        for obj in scene.objects:
            obj.location.x += 1.0

        return {'FINISHED'}            # Lets Blender know the operator finished successfully.

def register():
    bpy.utils.register_class(ObjectMoveX)

def unregister():
    bpy.utils.unregister_class(ObjectMoveX)

if __name__ == "__main__":
    register()
**System Information** Operating system: Mac OS 10.15.7 (19H114) Catalina Graphics card: ATI Radeon Vega **Blender Version** Broken: (example: 2.92, 02948a2cab44, master) Worked: dunno Running the script inside the Scripting editor doesn't do anything (![2021-04-03 22.04.48.gif](https://archive.blender.org/developer/F9919202/2021-04-03_22.04.48.gif)). I tried also to install as an addon (Preferences->Addons->Install) it adds the voice to add-ons and let to enable it but it ![2021-04-03 22.15.27.gif](https://archive.blender.org/developer/F9919211/2021-04-03_22.15.27.gif) won't add the option in the editor, so searching as reported in the tutorial doesn't work. There is no syntax error reported (tried also running form terminal the app to check if there were some error reported). Code copied from https://docs.blender.org/manual/en/latest/advanced/scripting/addon_tutorial.html: ``` bl_info = { "name": "Move X Axis", "blender": (2, 80, 0), "category": "Object" } import bpy from bpy import context class ObjectMoveX(bpy.types.Operator): """My Object Moving Script""" # Use this as a tooltip for menu items and buttons. bl_idname = "object.move_x" # Unique identifier for buttons and menu items to reference. bl_label = "Move X by One" # Display name in the interface. bl_options = {'REGISTER', 'UNDO'} # Enable undo for the operator. def execute(self, context): # execute() is called when running the operator. # The original script scene = bpy.context.scene for obj in scene.objects: obj.location.x += 1.0 return {'FINISHED'} # Lets Blender know the operator finished successfully. def register(): bpy.utils.register_class(ObjectMoveX) def unregister(): bpy.utils.unregister_class(ObjectMoveX) if __name__ == "__main__": register() ```
Author

Added subscriber: @Neogene

Added subscriber: @Neogene

Added subscriber: @rjg

Added subscriber: @rjg

Running it from the text editor will only register it, you have to call the operator to move the object as explained in the tutorial:

However running the script won’t move any objects. For this, you need to execute the newly registered operator.
Open the Operator Search menu and type in “Move X by One” (the bl_label), then Return.
The objects should move as before.

The steps to run the add-on from the text editor are:

  1. Create a new text data-block by pressing the New button in the text editor
  2. Copy and paste the script
  3. Run the script. Since executing the script like this will have __name__ set to "__main__" this will result in register() being called. The function registers the operator, but doesn't execute it.
  4. Since the operator is not part of any menu, Blender won't show it anywhere and it also won't appear in the regular search. Open the preferences Edit > Preferences > Interface and enable the Developer Extras and Python Tooltips. Once Developer Extras is enabled the search will also show operators that aren't in menus.
  5. Use Edit > Operator Search or press {key F3} and search for "Move X by One". Select the entry and press enter or double click on it. The operator will be executed.

Alternatively you can also run the operator without enabling the Developer Extras by using the Python console. Typing bpy.ops.object.move_x() and pressing enter will execute the operator.

Running it from the text editor will only register it, you have to call the operator to move the object as explained in the tutorial: > However running the script won’t move any objects. For this, you need to execute the newly registered operator. > Open the Operator Search menu and type in “Move X by One” (the `bl_label`), then Return. > The objects should move as before. The steps to run the add-on from the text editor are: 1. Create a new text data-block by pressing the *New* button in the text editor 2. Copy and paste the script 3. Run the script. Since executing the script like this will have `__name__` set to `"__main__"` this will result in `register()` being called. The function registers the operator, but doesn't execute it. 4. Since the operator is not part of any menu, Blender won't show it anywhere and it also won't appear in the regular search. Open the preferences *Edit > Preferences > Interface* and enable the *Developer Extras* and *Python Tooltips*. Once *Developer Extras* is enabled the search will also show operators that aren't in menus. 5. Use *Edit > Operator Search* or press {key F3} and search for "Move X by One". Select the entry and press enter or double click on it. The operator will be executed. Alternatively you can also run the operator without enabling the *Developer Extras* by using the Python console. Typing `bpy.ops.object.move_x()` and pressing enter will execute the operator.

Added subscriber: @Blendify

Added subscriber: @Blendify

@Blendify Since operators that aren't in menus are omitted from the search by default, the tutorial should explain that the Developer Extras have to be enabled or showcase it by calling the operator from the console.

@Blendify Since operators that aren't in menus are omitted from the search by default, the tutorial should explain that the *Developer Extras* have to be enabled or showcase it by calling the operator from the console.
Author

In #87180#1140738, @rjg wrote:
@Blendify Since operators that aren't in menus are omitted from the search by default, the tutorial should explain that the Developer Extras have to be enabled or showcase it by calling the operator from the console.

Yes I found to enable python in the tutorial and not also the developer extras. Thanks, after enabling it appeared and I managed to use and debug properly.

> In #87180#1140738, @rjg wrote: > @Blendify Since operators that aren't in menus are omitted from the search by default, the tutorial should explain that the *Developer Extras* have to be enabled or showcase it by calling the operator from the console. Yes I found to enable python in the tutorial and not also the developer extras. Thanks, after enabling it appeared and I managed to use and debug properly.
Member

Closed as duplicate of #85625

Closed as duplicate of #85625
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-manual#87180
No description provided.