I want to create the simplest addon, viewing the official documentation I found this, the problem is that I don´t see anything.
The code:

bl_info = {"name": "My Test Addon", "category": "Object"}
def register():
    print("Hello World")
def unregister():
    print("Goodbye World")

I try to install the addon. Open the user File -> User Preferences, Select the Addon section, press Install Addon... and select the file. I have to select a .py file, is not it? In my case I select the file "Simplestaddon.py" enter image description here I enable the addon enter image description here However I don´t see anything... enter image description here Where is "Hello World" supposed to appear? Apparenty, it´s supposed to see in the console but I did click on Window->Toggle System Console and I don´t see anything in the console after doing click on "Run script"

  • $\begingroup$ Really? All the simple addon above does is print to the system console when registered / unregistered. $\endgroup$ – batFINGER Jan 13 '18 at 9:16
  • $\begingroup$ Possible duplicate of Where does console output go $\endgroup$ – m.ardito Jan 13 '18 at 9:16
  • 1
    $\begingroup$ @batFINGER: I run the script and I don´t see anything in the system console. I can see the system console when I click on Window->Toggle System Console $\endgroup$ – Mr. Baldan Jan 13 '18 at 9:32
  • 1
    $\begingroup$ ... to register when script is run from text editor append the often seen if __name__ == "__main__": register() $\endgroup$ – batFINGER Jan 13 '18 at 10:32
  • 2
    $\begingroup$ Ok to spell this out as simply as possible. Start blender, open the system console, enable the addon and "Hello World" will be printed to system console, disable the addon and it's goodbye. To make the script register the addon when run in text editor add the code from my comment above. And might pay to read the documentation further before asking questions : Note Running this script within the text editor won’t print anything, to see the output it must be installed through the user preferences. Messages will be printed when enabling and disabling. $\endgroup$ – batFINGER Jan 13 '18 at 12:08

I finally understood what this script does! It is not displayed through any button or menu as expected at first. That´s logic because there is no code that refers to any button or menu. As a script it can not do anything either because it only contains the definitions of the functions but there is no call to any function. The only way to visualize its action is through Open the user File -> User Preferences, Select the Addon section. You write in the search box the name of your addon, in this case "My Test Addon". Once you show it, you give it to the square on the right, a checkbox, that action will enable it, if you press the checkbox again, you will disable it. Each time you enable it, it will write "Hello World" in the console (to see it click on Window-> Toggle System Console) and each time you disable it, "Goodbye World" will be written. enter image description here

  • $\begingroup$ I decided to publish my own answer because it seems the clearest because it is intended for people who are starting with blender and also with programming and have very little idea. They need to know the thinks with detail and step by step. Besides I think they need to see screens to know how things develop. $\endgroup$ – Mr. Baldan Jan 13 '18 at 12:40
  • 1
    $\begingroup$ Current Blender documentation is for version 2.78 the link posted is for 2.64. For an up to date link use api_current in the link Also only windows has the toggle system console. See the Use The Terminal link in the prerequisites I think 5 minutes reading the documentation and this question could have been avoided altogether. $\endgroup$ – batFINGER Jan 15 '18 at 15:37

The simplest possible script would look like this:

import bpy

print("Hello World")

And when you run this from the Script Editor in Blender, then you will see a Hello World in the console.

Registering a string like you try here does simply nothing. The print("Hello World") is usually an action that you call by a button for example. And this button is usually in a class for a panel or a menu. And this class needs to be registered and unregistered.

  • $\begingroup$ I don´t understand what it means what you wrote " And this button is usually in a class for a panel or a menu. And this class needs to be registered and unregistered." in terms of code and actions to perform over the blender GUI $\endgroup$ – Mr. Baldan Jan 13 '18 at 10:10
  • $\begingroup$ The script in question is simplest possible addon, demonstrating that at the very least an addon to be registered needs a bl_info dictionary and an unregister and register method.l $\endgroup$ – batFINGER Jan 13 '18 at 10:30
  • $\begingroup$ @batFINGER: But what I want to do is execute it, if the code is complete, why when I run it, do I not see anything even in the console? Sorry for my insistence, I'm new to blender and programming too. I often need to explain things step by step in order to run them. Many questions I see on this site are answered with "do this and this other" but the problem for which we are new is that many times we do not know how to "do this and this other". $\endgroup$ – Mr. Baldan Jan 13 '18 at 10:58
  • $\begingroup$ @batFINGER, yeah, but the problem is the script part. The addon part already works. Mr.Baldan, it means that you don't register single operators, but you register classes. The register function just registers the classes in the script so that they can be used at a later point. They don't do anything besides registering. I would suggest to have a look at the code examples that comes with Blender. $\endgroup$ – Tiles Jan 13 '18 at 11:29
  • $\begingroup$ @Tiles: Where are the code examples are you talking about? I found the code in the official documentation, docs.blender.org/api/blender_python_api_2_64_9/… $\endgroup$ – Mr. Baldan Jan 13 '18 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.