Partially Loading Project Files
When opening a project, loading all divided model units may take time depending on the size of the model units.
Therefore, you can optionally specify not to load model units when opening the project.
Also, if you need the design information of a model unit, you can specify and load the model unit.
After opening the project, model files (model units) are loaded in the background, and unloaded models are loaded when needed. However, model files with manual load settings will not be loaded even if referenced from scripts or extensions. They are only loaded through screen operations and when explicitly loaded using methods such as LoadModelUnits. For details, please refer to Changes in V5.1.
Loading Only Project Files
To load only the project file without loading model units, specify true for the excludeModelFiles option in the OpenProject method of the IWorkspace object.
public void OpenProject(ICommandContext c, ICommandParams p)
{
//Select the project file
var filePath = c.App.Window.UI.ShowOpenFileDialog("Please select a project file.", "Project files|_.iproj;_.nproj");
if ( filePath == null ) return "Cancelled.";
//Open the project file without loading model units
c.App.Workspace.OpenProject(filePath, excludeModelFiles: true);
}
Loading Additional Model Files
Model units that were not loaded when opening the project can be loaded later. This is called additional loading.
Additional loading is done using the LoadModelUnits method of the IWorkspace object.
public void LoadModelUnits(ICommandContext c, ICommandParams p)
{
//Get the model units that haven't been loaded yet in the current project
IProjectUnitManager unitManager = c.App.Workspace.CurrentProject.UnitManager;
var notLoadedUnits = unitManager.ModelUnits.Where(unit => !unit.Loaded).ToList();
//Add the unloaded model units to the current project
IWorkspace workspace = c.App.Workspace;
workspace.LoadModelUnits(c.App.Workspace.CurrentProject, notLoadedUnits);
}