I have a script, it is divided in three files, one for the UI and two operators, I’m pretty new to python in Blender (and Python in general) and I’m trying to find a guide on how to pack everything as an addon where I don’t need to manually execute the three files to have it in Blender so I can release it and anyone could be able to install it through the preferences addon tab.
So, to be clear, can someone point me out towards a tutorial where I can see how to pack my 3-files script as an addon?
I am not sure about tutorials but what was extremely usefull for myself were all the example files that come with Blender - in Blender’s Text Editor panel’s header there is a menu ‘Templates’ That is awsome place to start and you can also open up any addons that come with Blender or if you download them.
Thanks MartinZ, It’s what I did to make my first addon, checking out the templates, but there are things that are yet out of my understanding, so I need some guidance for some things, but thanks for the advice, appreciate it
To be honest, I did not know quite a few things in the tutorials. That’s going to make my life easier as well. Thanks a lot for the recommendation, Korchy!
Korchy after following your multifile addon tutorial I’ve created the init.py and it loads and appears in the addons tab of preferences, but when I enable it it gaves me an error that I cannot identify:
Traceback (most recent call last):
File "D:\3D\BlenderBB\blender-2.79.0_18_08_2017\2.79\scripts\modules\addon_utils.py", line 331, in enable
mod = __import__(module_name)
File "C:\Users\jgea\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\modifyPivot\__init__.py", line 19, in <module>
for currentModuleFullName in modulesFullNames.values():
AttributeError: 'list' object has no attribute 'values'
This is my init.py
bl_info = {
'name': 'Modify Pivot',
'version': (0, 0, 1),
'blender': (2, 79, 0),
'location': 'Tools panel.',
'description': 'Tool to modify pivot location and orientation.',
'category': 'Object',
}
modulesNames = ['BSModifyPivotPanel', 'BSModifyPivotCreate', 'BSModifyPivotCommit']
modulesFullNames = []
for currentModuleName in modulesNames:
modulesFullNames.append('{}.{}'.format(__name__, currentModuleName))
import sys
import importlib
for currentModuleFullName in modulesFullNames.values():
if currentModuleFullName in sys.modules:
importlib.reload(sys.modules[currentModuleFullName])
else:
globals()[currentModuleFullName] = importlib.import_module(currentModuleFullName)
setattr(globals()[currentModuleFullName], 'modulesNames', modulesFullNames)
def register():
for currentModuleName in modulesFullNames.values():
if currentModuleName in sys.modules:
if hasattr(sys.modules[currentModuleName], 'register'):
sys.modules[currentModuleName].register()
def unregister():
for currentModuleName in modulesFullNames.values():
if currentModuleName in sys.modules:
if hasattr(sys.modules[currentModuleName], 'unregister'):
sys.modules[currentModuleName].unregister()
if __name__ == "__main__":
register()