Пример #1
0
def unregister():
    unregister_nodes()

    # Ensure that globals are reset if the addon is enabled again in the same Blender session
    arm_nodes.reset_globals()

    bpy.utils.unregister_class(ReplaceNodesOperator)
    bpy.utils.unregister_class(ArmLogicTree)
    bpy.utils.unregister_class(ARM_PT_LogicNodePanel)
    bpy.utils.unregister_class(ArmOpenNodeHaxeSource)
    bpy.utils.unregister_class(ArmOpenNodePythonSource)
    bpy.utils.unregister_class(ArmOpenNodeWikiEntry)
    bpy.utils.unregister_class(ARM_PT_Variables)
    bpy.utils.unregister_class(ARMAddVarNode)
    bpy.utils.unregister_class(ARMAddSetVarNode)
    bpy.utils.unregister_class(ARM_OT_AddNodeOverride)
    bpy.utils.unregister_class(ARM_MT_NodeAddOverride)
    bpy.utils.register_class(ARM_MT_NodeAddOverride.overridden_menu)

    arm.logicnode.arm_sockets.unregister()
Пример #2
0
def load_libraries():
    lib_path = os.path.join(arm.utils.get_fp(), 'Libraries')
    if os.path.exists(lib_path):
        # Don't register nodes twice when calling register_nodes()
        arm_nodes.reset_globals()

        # Make sure that Armory's categories are registered first (on top of the menu)
        arm.logicnode.init_categories()

        libs = os.listdir(lib_path)
        for lib in libs:
            fp = os.path.join(lib_path, lib)
            if os.path.isdir(fp):
                if fp not in appended_py_paths and os.path.exists(
                        os.path.join(fp, 'blender.py')):
                    appended_py_paths.append(fp)
                    sys.path.append(fp)
                    import blender
                    importlib.reload(blender)
                    blender.register()
                    sys.path.remove(fp)

        # Register newly added nodes and node categories
        arm.nodes_logic.register_nodes()
Пример #3
0
def load_py_libraries():
    if bpy.data.filepath == '':
        # When a blend file is opened from the file explorer, Blender
        # first opens the default file and then the actual blend file,
        # so this function is called twice. Because the cwd is already
        # that of the folder containing the blend file, libraries would
        # be loaded/unloaded once for the default file which is not needed.
        return

    lib_path = os.path.join(arm.utils.get_fp(), 'Libraries')
    if os.path.exists(lib_path):
        # Don't register nodes twice when calling register_nodes()
        arm_nodes.reset_globals()

        # Make sure that Armory's categories are registered first (on top of the menu)
        arm.logicnode.init_categories()

        libs = os.listdir(lib_path)
        for lib_name in libs:
            fp = os.path.join(lib_path, lib_name)
            if os.path.isdir(fp):
                if os.path.exists(os.path.join(fp, 'blender.py')):
                    sys.path.append(fp)

                    lib_module = importlib.import_module('blender')
                    importlib.reload(lib_module)
                    if hasattr(lib_module, 'register'):
                        lib_module.register()

                    log.debug(f'Armory: Loaded Python library {lib_name}')
                    loaded_py_libraries[lib_name] = lib_module

                    sys.path.remove(fp)

        # Register newly added nodes and node categories
        arm.nodes_logic.register_nodes()