3
$\begingroup$

I'm trying to learn how to create a multifile addon, but its getting hard, I've tried out some ways but no sucess. the method that better worked was this. but it is giving me an error on line 17 now 'TypeError: ("reload() argumment must be module")' someone can help?

bl_info = {
    "name": "driven_shapes",
    "description": "",
    "author": "Your Name",
    "version": (0, 0, 1),
    "blender": (2, 78, 0),
    "location": "View3D",
    "warning": "This addon is still in development.",
    "wiki_url": "",
    "category": "Object" }


if "bpy" in locals():
    import importlib


    importlib.reload("shapesplit")
    importlib.reload("driver_add")
    importlib.reload("ui")
else:
    from . import shapesplit
    from . import driver_add
    from . import ui

def register():
    bpy.utils.register_module(__name__)

def unregister():
    bpy.utils.unregister_module(__name__)

if __name__ == "__main__":
    register()
$\endgroup$
2
$\begingroup$

You are getting the TypeError because of passing a string argument to the reload function. reload function expects a module object as its argument.

You could create a mapping of the modules you want reloaded and then pass the mapping's value to reload.

You can refer to an example from Blender's UI module for a thorough example.

scripts/startup/bl_ui/init.py

reloading modules

building a mapping of modules to reload

$\endgroup$
  • $\begingroup$ That is great. In general I have found Blender's factory Python scripts to be of high quality and a great resource to learn from. $\endgroup$ – satishgoda Jun 3 '17 at 15:51

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.