Get the model selected in the editor
To get the model selected in the editor, use the SelectedModels
property of the IEditorView
object.
public void GetSelectedModels(ICommandContext c, ICommandParams p)
{
IEditorView editor = c.App.Window.EditorPage?.CurrentEditorView;
if (editor == null) {
c.App.Window.UI.ShowMessageBox("Please display the editor before executing.");
return;
}
IModelCollection models = editor.SelectedModels;
foreach(var model in models)
{
c.App.Output.WriteLine("sample", "Model selected in editor: " + model.Name);
}
}