def execute_extension_startup_script(script_path, ext_name, sys_paths=None): """Executes a script using pyRevit script executor. Args: script_path (str): Address of the script file Returns: results dictionary from the executed script """ core_syspaths = [MAIN_LIB_DIR, MISC_LIB_DIR] if sys_paths: sys_paths.extend(core_syspaths) else: sys_paths = core_syspaths script_data = runtime.types.ScriptData() script_data.ScriptPath = script_path script_data.ConfigScriptPath = None script_data.CommandUniqueId = '' script_data.CommandName = 'Starting {}'.format(ext_name) script_data.CommandBundle = '' script_data.CommandExtension = ext_name script_data.HelpSource = '' script_runtime_cfg = runtime.types.ScriptRuntimeConfigs() script_runtime_cfg.CommandData = create_tmp_commanddata() script_runtime_cfg.SelectedElements = None script_runtime_cfg.SearchPaths = framework.List[str](sys_paths or []) script_runtime_cfg.Arguments = framework.List[str]([]) script_runtime_cfg.EngineConfigs = \ runtime.create_ipyengine_configs( clean=True, full_frame=True, persistent=True, ) script_runtime_cfg.RefreshEngine = False script_runtime_cfg.ConfigMode = False script_runtime_cfg.DebugMode = False script_runtime_cfg.ExecutedFromUI = False runtime.types.ScriptExecutor.ExecuteScript( script_data, script_runtime_cfg )
def create_executor_type(extension, module_builder, cmd_component): """ Args: module_builder: cmd_component (pyrevit.extensions.genericcomps.GenericUICommand): Returns: """ cmd_component.requires_clean_engine = \ _does_need_clean_engine(extension, cmd_component) engine_configs = runtime.create_ipyengine_configs( clean=cmd_component.requires_clean_engine, full_frame=cmd_component.requires_fullframe_engine, persistent=cmd_component.requires_persistent_engine, ) bundletypemaker.create_executor_type(extension, module_builder, cmd_component, eng_cfgs=engine_configs)