Skip to main content

Loading a partial project file

When opening a project, loading all the divided model units may take some time depending on the size of the model units. Therefore, when opening a project, you can specify an option not to load model units. Also, if you need design information for a model unit, you can specify and load the model unit.

Loading only the project file​

To load only the project file without loading the model units, specify true for the excludeModelFiles option of the OpenProject method of the IWorkspace object.

public void OpenProject(ICommandContext c, ICommandParams p)
{
//Select a project file
var filePath = c.App.Window.UI.ShowOpenFileDialog("Please select a project file.", "Project file|*.iproj;*.nproj");
if (filePath == null) return "Cancelled.";

//Open a project file without loading model units
c.App.Workspace.OpenProject(filePath, excludeModelFiles: true);
}

Load additional model files​

You can load additional model units that were not loaded when opening a project. 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 in the current project that are not yet loaded.
IProjectUnitManager unitManager = c.App.Workspace.CurrentProject.UnitManager;
var notLoadedUnits = unitManager.ModelUnits.Where(unit => !unit.Loaded).ToList();
//Load the model units that are not yet loaded into the current project.
IWorkspace workspace = c.App.Workspace;
workspace.LoadModelUnits(c.App.Workspace.CurrentProject, notLoadedUnits);
}