Ejemplo n.º 1
0
def register():
    print("\n### Loading CATS...")

    # Load settings
    tools.settings.load_settings()

    # if not tools.settings.use_custom_mmd_tools():
    #     bpy.utils.unregister_module("mmd_tools")

    # Load mmd_tools
    try:
        mmd_tools_local.register()
    except AttributeError:
        print('Could not register local mmd_tools')
        pass

    # Register updater
    try:
        addon_updater_ops.register(bl_info)
    except ValueError as e:
        print('\n!!! Error while registering Updater:\n' + str(e) + '\n')
        pass

    # Register all classes
    count = 0
    tools.register.order_classes()
    for cls in tools.register.__bl_ordered_classes:
        # print(cls)
        bpy.utils.register_class(cls)
        count += 1
    print('Registered', count, 'CATS classes.')

    # Register Scene types
    extend_types.register()

    # Set cats version string
    tools.common.set_cats_verion_string()

    # Load supporter and settings icons and buttons
    tools.supporter.load_other_icons()
    tools.supporter.load_supporters()
    tools.supporter.register_dynamic_buttons()

    # Load the dictionaries and check if they are found
    globs.dict_found = tools.translate.load_translations()

    # Set preferred Blender options
    bpy.context.user_preferences.system.use_international_fonts = True
    bpy.context.user_preferences.filepaths.use_file_compression = True

    # Add shapekey button to shapekey menu
    bpy.types.MESH_MT_shape_key_specials.append(
        tools.shapekey.addToShapekeyMenu)

    # Disable request warning when using google translate
    requests.packages.urllib3.disable_warnings(
        requests.packages.urllib3.exceptions.InsecureRequestWarning)

    # Apply the settings after a short time, because you can't change checkboxes during register process
    tools.settings.start_apply_settings_timer()

    print("### Loaded CATS successfully!")
Ejemplo n.º 2
0
def register():
    print("\n### Loading CATS...")

    # Check for unsupported Blender versions
    check_unsupported_blender_versions()

    # Check for faulty CATS installations
    remove_corrupted_files()

    # Set cats version string
    version_str = set_cats_version_string()

    # Register Updater and check for CATS update
    updater.register(bl_info, dev_branch, version_str)

    # Set some global settings, first allowed use of globs
    globs.dev_branch = dev_branch
    globs.version_str = version_str

    # Load settings and show error if a faulty installation was deleted recently
    show_error = False
    try:
        tools.settings.load_settings()
    except FileNotFoundError:
        show_error = True
    if show_error:
        sys.tracebacklimit = 0
        raise ImportError('\n\nPlease restart Blender and enable CATS again!'
                          '\n')

    # if not tools.settings.use_custom_mmd_tools():
    #     bpy.utils.unregister_module("mmd_tools")

    # Load mmd_tools
    try:
        mmd_tools_local.register()
    except AttributeError:
        print('Could not register local mmd_tools')
    except ValueError:
        print('mmd_tools is already registered')

    # Register all classes
    count = 0
    tools.register.order_classes()
    for cls in tools.register.__bl_classes:
        try:
            bpy.utils.register_class(cls)
            count += 1
        except ValueError:
            pass
    # print('Registered', count, 'CATS classes.')
    if count < len(tools.register.__bl_classes):
        print('Skipped',
              len(tools.register.__bl_classes) - count, 'CATS classes.')

    # Register Scene types
    extentions.register()

    # Load supporter and settings icons and buttons
    tools.supporter.load_other_icons()
    tools.supporter.load_supporters()
    tools.supporter.register_dynamic_buttons()

    # Load the dictionaries and check if they are found.
    globs.dict_found = tools.translate.load_translations()

    # Set preferred Blender options
    if hasattr(tools.common.get_user_preferences(), 'system') and hasattr(
            tools.common.get_user_preferences().system,
            'use_international_fonts'):
        tools.common.get_user_preferences(
        ).system.use_international_fonts = True
    elif hasattr(tools.common.get_user_preferences(), 'view') and hasattr(
            tools.common.get_user_preferences().view,
            'use_international_fonts'):
        tools.common.get_user_preferences().view.use_international_fonts = True
    else:
        pass  # From 2.83 on this is no longer needed
    tools.common.get_user_preferences().filepaths.use_file_compression = True
    bpy.context.window_manager.addon_support = {
        'OFFICIAL', 'COMMUNITY', 'TESTING'
    }

    # Add shapekey button to shapekey menu
    if hasattr(bpy.types, 'MESH_MT_shape_key_specials'):  # pre 2.80
        bpy.types.MESH_MT_shape_key_specials.append(
            tools.shapekey.addToShapekeyMenu)
    else:
        bpy.types.MESH_MT_shape_key_context_menu.append(
            tools.shapekey.addToShapekeyMenu)

    # Disable request warning when using google translate
    requests.packages.urllib3.disable_warnings(
        requests.packages.urllib3.exceptions.InsecureRequestWarning)

    # Monkey patch fbx exporter to include empty shapekeys
    tools.fbx_patch.start_patch_fbx_exporter_timer()

    # Apply the settings after a short time, because you can't change checkboxes during register process
    tools.settings.start_apply_settings_timer()

    print("### Loaded CATS successfully!\n")
Ejemplo n.º 3
0
def register():
    print("\n### Loading CATS...")

    # Check for faulty CATS installations
    remove_corrupted_files()

    # Set cats version string
    version_str = set_cats_version_string()

    # Register Updater and check for CATS update
    print("Loading Updater..")
    updater.register(bl_info, dev_branch, version_str)

    # Set some global settings, first allowed use of globs
    globs.dev_branch = dev_branch
    globs.version_str = version_str

    # Load settings and show error if a faulty installation was deleted recently
    print("Loading settings..")
    show_error = False
    try:
        tools.settings.load_settings()
    except FileNotFoundError:
        show_error = True
    if show_error:
        sys.tracebacklimit = 0
        raise ImportError(
            '                                                                                                                                                                                    '
            '                     '
            '\n\nPlease restart Blender and enable CATS again!                                                            Please restart Blender and enable CATS again!'
            '\n\n\n\nPlease restart Blender and enable CATS again!'
            '\n\n\n\nPlease restart Blender and enable CATS again!'
            '\n\n\n\nPlease restart Blender and enable CATS again!'
            '\n\n\n\n')

    # if not tools.settings.use_custom_mmd_tools():
    #     bpy.utils.unregister_module("mmd_tools")

    # Load mmd_tools
    print("Loading mmd_tools..")
    try:
        mmd_tools_local.register()
    except AttributeError:
        print('Could not register local mmd_tools')
        pass

    # Register all classes
    print('Registering CATS classes..')
    count = 0
    tools.register.order_classes()
    for cls in tools.register.__bl_classes:  # TODO ordered
        # print(cls)
        bpy.utils.register_class(cls)
        count += 1
    print('Registered', count, 'CATS classes.')

    # Register Scene types
    print("Registering scene types..")
    extentions.register()

    # Load supporter and settings icons and buttons
    print("Loading other stuff..")
    tools.supporter.load_other_icons()
    tools.supporter.load_supporters()
    tools.supporter.register_dynamic_buttons()

    # Load the dictionaries and check if they are found
    globs.dict_found = tools.translate.load_translations()

    # Set preferred Blender options
    tools.common.get_user_preferences().system.use_international_fonts = True
    tools.common.get_user_preferences().filepaths.use_file_compression = True

    # Add shapekey button to shapekey menu
    bpy.types.MESH_MT_shape_key_specials.append(
        tools.shapekey.addToShapekeyMenu)

    # Disable request warning when using google translate
    requests.packages.urllib3.disable_warnings(
        requests.packages.urllib3.exceptions.InsecureRequestWarning)

    # Apply the settings after a short time, because you can't change checkboxes during register process
    tools.settings.start_apply_settings_timer()

    print("### Loaded CATS successfully!\n")