Skip to content

Commit

Permalink
Update extension initialization code
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarEmaraDev committed Dec 15, 2020
1 parent 5ba5578 commit d945e57
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions content/developer_guide/extensions/introduction/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ described later in the Cython [section](#cython).

## Initialization

In the top-level `__init__.py` file, we need to do two things:
In the top-level `__init__.py` file, we need to do three things:

- Make sure Animation Nodes is loaded and available.
- Initialize the automatic loader and register/unregister the classes.
- Update socket information. This is only needed if you define new sockets.

```python
'''
Expand Down Expand Up @@ -87,13 +88,16 @@ import bpy
import addon_utils
from . import auto_load

if not all(addon_utils.check("animation_nodes")):
module = addon_utils.enable("animation_nodes", default_set = False, persistent = True)
if not module:
try: import animation_nodes
except:
animation_nodes = addon_utils.enable("animation_nodes", default_set = False, persistent = True)
if not animation_nodes:
raise Exception("Could not load Animation Nodes.")

auto_load.init()

animation_nodes.sockets.info.updateSocketInfo()

def register():
auto_load.register()

Expand Down

0 comments on commit d945e57

Please sign in to comment.