Get the model selected in the model navigator
To get the model selected in the model navigator, use the SelectedItems
property of the INavigator
object.
public void GetSelectedModelsByNavigator(ICommandContext c, ICommandParams p)
{
IEditorPage editorPage = c.App.Window.EditorPage;
if (editorPage.ActiveNavigator != "Model")
{
c.App.Window.UI.ShowMessageBox("Please switch to the model navigator before executing.");
return;
}
//Get the models selected in the model navigator
var selectedModels = editorPage.CurrentNavigator.SelectedItems.OfType<IModel>();
foreach (IModel model in selectedModels)
{
c.App.Output.WriteLine("sample", $"Model: {model.Name}");
}
}