Hi @Andrej730 , i took a look on the reload script feature. I still have issues on certain classes, that i appear to unregister right but can't register again. with a 'missing bl_rna attribute... ' message. (see below)
That, i don't know what to do with, as it makes the all script really unsafe (as in the end Classes are not available anymore at all).
I surely misunderstand something, but may be you have a clue on what's happening here ?
unregistering Class <class 'blenderbim.bim.module.demo.prop.BIMDemoProperties'>
Reregistering Class <class 'blenderbim.bim.module.demo.prop.BIMDemoProperties'>
Error: Python: Traceback (most recent call last):
File "\bbim_reload_recursive.py", line 42, in <module>
File "\bbim_reload_recursive.py", line 34, in reregister_modules_recursive
File "\bbim_reload_recursive.py", line 19, in reregister_modules_recursive
RuntimeError: register_class(...):, missing bl_rna attribute from 'RNAMetaPropGroup' instance (may not be registered)
The code i run is this one:
import bpy
import importlib
import inspect
reregister_modules = ["blenderbim.bim.module.demo"]
def reregister_modules_recursive(module_name):
print('Module ', module_name)
module = importlib.import_module(module_name)
# retrieving registered classes with inspect
classes = [c[1] for c in inspect.getmembers(module, inspect.isclass)]
# reregistering classes
for c in classes:
if hasattr(c, 'is_registered') and c.is_registered:
print('unregistering Class', c , 'is_registered', c.is_registered)
bpy.utils.unregister_class(c)
print('Reregistering Class', c)
bpy.utils.register_class(c)
try:
print('reloading ', module)
importlib.reload(module)
except Exception as e:
print('error reimporting ', module, e)
sub_modules=[]
for n, sm in inspect.getmembers(module, inspect.ismodule):
# We should avoid reparsing upper modules here like bpy. so i check if sub module contains module name
if module_name in sm.__name__:
sub_modules.append(sm.__name__)
for module_name in sub_modules:
reregister_modules_recursive(module_name)
for module_name in reregister_modules:
print('-'*60)
print('Reregistering utility')
reregister_modules_recursive(module_name)
print('done')
print('-'*60)