コード例 #1
0
ファイル: sessionmgr.py プロジェクト: kjanik11/pyRevit
def _new_session():
    """
    Get all installed extensions (UI extension only) and creates an assembly,
    and a ui for each.

    Returns:
        None
    """
    # get all installed ui extensions
    for ui_ext in get_installed_ui_extensions():
        # create a dll assembly and get assembly info
        ext_asm_info = create_assembly(ui_ext)
        if not ext_asm_info:
            logger.critical('Failed to create assembly for: {}'.format(ui_ext))
            continue

        logger.info('Extension assembly created: {}'.format(ui_ext.name))

        # update/create ui (needs the assembly to link button actions
        # to commands saved in the dll)

        update_pyrevit_ui(
            ui_ext, ext_asm_info,
            user_config.core.get_option('loadbeta', default_value=False))
        logger.info('UI created for extension: {}'.format(ui_ext.name))

    # cleanup existing UI. This is primarily for cleanups after reloading
    cleanup_pyrevit_ui()
コード例 #2
0
ファイル: sessionmgr.py プロジェクト: xulian070608/pyRevit
def _new_session():
    """
    Get all installed extensions (UI extension only) and creates an assembly,
    and a ui for each.

    Returns:
        None
    """

    assembled_exts = []
    # get all installed ui extensions
    for ui_ext in extensionmgr.get_installed_ui_extensions():
        # configure extension components for metadata
        # e.g. liquid templates like {{author}}
        ui_ext.configure()

        # create a dll assembly and get assembly info
        ext_asm_info = asmmaker.create_assembly(ui_ext)
        if not ext_asm_info:
            mlogger.critical('Failed to create assembly for: %s', ui_ext)
            continue
        else:
            mlogger.info('Extension assembly created: %s', ui_ext.name)

        assembled_exts.append(AssembledExtension(ext=ui_ext,
                                                 assm=ext_asm_info))

    # add names of the created assemblies to the session info
    sessioninfo.set_loaded_pyrevit_assemblies(
        [x.assm.name for x in assembled_exts])

    # run startup scripts for this ui extension, if any
    for assm_ext in assembled_exts:
        if assm_ext.ext.startup_script:
            # build syspaths for the startup script
            sys_paths = [assm_ext.ext.directory]
            if assm_ext.ext.library_path:
                sys_paths.insert(0, assm_ext.ext.library_path)

            mlogger.info('Running startup tasks for %s', assm_ext.ext.name)
            mlogger.debug('Executing startup script for extension: %s',
                          assm_ext.ext.name)

            # now run
            execute_script(assm_ext.ext.startup_script, sys_paths=sys_paths)

    # update/create ui (needs the assembly to link button actions
    # to commands saved in the dll)
    for assm_ext in assembled_exts:
        uimaker.update_pyrevit_ui(
            assm_ext.ext, assm_ext.assm,
            user_config.core.get_option('loadbeta', default_value=False))
        mlogger.info('UI created for extension: %s', assm_ext.ext.name)

    # re-sort the ui elements
    for assm_ext in assembled_exts:
        uimaker.sort_pyrevit_ui(assm_ext.ext)

    # cleanup existing UI. This is primarily for cleanups after reloading
    uimaker.cleanup_pyrevit_ui()
コード例 #3
0
def _new_session():
    """
    Get all installed extensions (UI extension only) and creates an assembly,
    and a ui for each.

    Returns:
        None
    """

    loaded_assm_list = []
    # get all installed ui extensions
    for ui_ext in get_installed_ui_extensions():
        # create a dll assembly and get assembly info
        ext_asm_info = create_assembly(ui_ext)
        if not ext_asm_info:
            logger.critical('Failed to create assembly for: {}'
                            .format(ui_ext))
            continue

        logger.info('Extension assembly created: {}'.format(ui_ext.name))

        # add name of the created assembly to the session info
        loaded_assm_list.append(ext_asm_info.name)

        # run startup scripts for this ui extension, if any
        if ui_ext.startup_script:
            logger.info('Running startup tasks...')
            logger.debug('Executing startup script for extension: {}'
                         .format(ui_ext.name))
            execute_script(ui_ext.startup_script)

        # update/create ui (needs the assembly to link button actions
        # to commands saved in the dll)

        update_pyrevit_ui(ui_ext,
                          ext_asm_info,
                          user_config.core.get_option('loadbeta',
                                                      default_value=False))
        logger.info('UI created for extension: {}'.format(ui_ext.name))

    # add names of the created assemblies to the session info
    sessioninfo.set_loaded_pyrevit_assemblies(loaded_assm_list)

    # cleanup existing UI. This is primarily for cleanups after reloading
    cleanup_pyrevit_ui()
コード例 #4
0
ファイル: sessionmgr.py プロジェクト: giangdip2410/pyRevit
def _new_session():
    """
    Get all installed extensions (UI extension only) and creates an assembly,
    and a ui for each.

    Returns:
        None
    """

    assembled_exts = []
    # get all installed ui extensions
    for ui_ext in extensionmgr.get_installed_ui_extensions():
        # configure extension components for metadata
        # e.g. liquid templates like {{author}}
        ui_ext.configure()

        # collect all module references from extensions
        ui_ext_modules = ui_ext.get_all_modules()
        # make sure they are all loaded
        assmutils.load_asm_files(ui_ext_modules)
        # and update env information
        sessioninfo.update_loaded_pyrevit_referenced_modules(ui_ext_modules)

        # create a dll assembly and get assembly info
        ext_asm_info = asmmaker.create_assembly(ui_ext)
        if not ext_asm_info:
            mlogger.critical('Failed to create assembly for: %s', ui_ext)
            continue
        else:
            mlogger.info('Extension assembly created: %s', ui_ext.name)

        assembled_exts.append(
            AssembledExtension(ext=ui_ext, assm=ext_asm_info)
        )

    # add names of the created assemblies to the session info
    sessioninfo.set_loaded_pyrevit_assemblies(
        [x.assm.name for x in assembled_exts]
    )

    # run startup scripts for this ui extension, if any
    for assm_ext in assembled_exts:
        if assm_ext.ext.startup_script:
            # build syspaths for the startup script
            sys_paths = [assm_ext.ext.directory]
            if assm_ext.ext.library_path:
                sys_paths.insert(0, assm_ext.ext.library_path)

            mlogger.info('Running startup tasks for %s', assm_ext.ext.name)
            mlogger.debug('Executing startup script for extension: %s',
                          assm_ext.ext.name)

            # now run
            execute_extension_startup_script(
                assm_ext.ext.startup_script,
                assm_ext.ext.name,
                sys_paths=sys_paths
                )

    # register extension hooks
    for assm_ext in assembled_exts:
        hooks.register_hooks(assm_ext.ext)

    # update/create ui (needs the assembly to link button actions
    # to commands saved in the dll)
    for assm_ext in assembled_exts:
        uimaker.update_pyrevit_ui(
            assm_ext.ext,
            assm_ext.assm,
            user_config.load_beta
        )
        mlogger.info('UI created for extension: %s', assm_ext.ext.name)

    # re-sort the ui elements
    for assm_ext in assembled_exts:
        uimaker.sort_pyrevit_ui(assm_ext.ext)

    # cleanup existing UI. This is primarily for cleanups after reloading
    uimaker.cleanup_pyrevit_ui()

    # reflow the ui if requested, depending on the language direction
    if user_config.respect_language_direction:
        current_applocale = applocales.get_current_applocale()
        uimaker.reflow_pyrevit_ui(direction=current_applocale.lang_dir)
    else:
        uimaker.reflow_pyrevit_ui()