Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have tried a few examples found on the forum and on the documentation, but I was never able to set the selection at the end of the command.
Below is a simple test that is supposed to keep selected only the first pre-selected entity.
You can test it by selecting a few entities and running the command. After the the command exits, only the first pre-selected entity should be selected. Instead nothing is selected.
[CommandMethod("TestRemoveItemFromPreselection", CommandFlags.UsePickSet)]
public void TestRemoveItemFromPreselection()
{
var ed = Application.DocumentManager.MdiActiveDocument.Editor;
var selectionResult = ed.SelectImplied();
if (selectionResult.Status != PromptStatus.OK)
{
ed.WriteMessage($"selectionResult.Status: {selectionResult.Status}");
return;
}
var selectionSet = selectionResult.Value;
var ids = new ObjectIdCollection(selectionSet.GetObjectIds());
var ids2 = new ObjectId[1];
ids2[0] = ids[0];
ed.SetImpliedSelection(ids2);
}
Solved! Go to Solution.