Thanks for your fast answer, the first option unfortunately does not work.
Reselecting an Edge (Connector) works like a charm, however i have some questions about the SelectedObjects collection.
This is my code right now:
EA.ObjectType oType = repository.GetContextItem(out obj);
if (oType == EA.ObjectType.otConnector)
repository.GetCurrentDiagram().SelectedConnector = (EA.Connector)obj;
else if (oType == EA.ObjectType.otElement)
Collection newSelection = repository.GetCurrentDiagram().SelectedObjects;
EA.Element dObj = (EA.Element)obj;
IDualElement el = repository.GetCurrentDiagram().SelectedObjects.AddNew(dObj.ElementID.ToString(),
newSelection = repository.GetCurrentDiagram().SelectedObjects;
This code works for reselecting the object (obj), however when looking at the documentation it states that i should:
-modify the returned object
-call Update() on the returned object
-call Refresh() on the collection
However, the object returned by AddNew() (el) for me is always null, making it difficult to call Update() on it...
Also if i were to call Refresh() on the SelectedObjects collection, it would remove my item I added with AddNew().
How do I implement this the correct way?
Are there any problems i will run into if i leave my code this way?