Delete a model directly under a project
To delete a model directly under a project, call the Delete
method of the IModel
object for the model obtained by Get models directly under a project.
public void DeleteRootModels(ICommandContext c, ICommandParams p)
{
IProject project = c.App.Workspace.CurrentProject;
//Get the design model root (root model in the model navigator)
IModel designModel = project.DesignModel;
//Get the models directly under the project
IModelCollection rootModels = project.GetRootChildren();
foreach (IModel rootModel in rootModels.ToList())
{
rootModel.Delete();
}
}