
I know it should be simple but I am missing something basic here:
For the Add method all I want to do is get an element and put it on the diagram
this simplify what I wrote:
private addToDiagram(EA.Repository repository,EA.Element someElement)
{
EA.Diagram diagram = repository.GetCurrentDiagram();
EA.DiagramObject a = diagram.DiagramObjects.AddNew(someElement.Name, someElement.Type);
a.ElementID = selected.ElementID;
a.Update(); //The update is throwing an exception
diagram.Update();
}
In debugger I see the element Id is getting updated, but the Update throws an exception.
For the delete function, all it should do is get element an element which is on the diagram and delete it:
private deleteFromDiagram(EA.Repository repository,EA.Element someElement)
{
EA.Diagram diagram = repository.GetCurrentDiagram();
short id = (short)selected.ElementID;
diagram.DiagramObjects.DeleteAt(id, true); //this line throws an exception for a valid element
diagram.Update();
}
Again, what is wrong with this delete?
Tzafrir