Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: SomersetGraham on March 16, 2010, 02:32:57 am

Title: Correct way to replace a diagram
Post by: SomersetGraham on March 16, 2010, 02:32:57 am
Hi everyone
For a given element I want to discover if a diagram exists for a given name and if so replace it with a new one of that name
What I am doing is the following, it works BUT I get a warning dialog in EA stating that the underlying model data is out of date and to press OK to do a refresh. Doing so results in the model that I want, but obvouisly I dont want the dialog to appear.

What have I missed

Graham
Code: [Select]
short diagramIndex = 0;
foreach (EA.Diagram diag in CurrentlySelectedElement.Diagrams)
{
    if (diag.Name == CurrentlySelectedElement.Name + " xxxx")
    {
        CurrentlySelectedElement.Diagrams.DeleteAt(diagramIndex, true);
        CurrentlySelectedElement.Diagrams.Refresh();
        CurrentlySelectedElement.Update();
        break;
    }
    diagramIndex++;
}
EA.Diagram newDiagram = (EA.Diagram)
                                    CurrentlySelectedElement.Diagrams.AddNew
                                   (CurrentlySelectedElement.Name + "
                                     xxxx", "Analysis");
                  
newDiagram.DiagramObjects.Refresh();
newDiagram.Update();
CurrentlySelectedElement.Diagrams.Refresh();
CurrentlySelectedElement.Update();
Repository.OpenDiagram(newDiagram.DiagramID);

Title: Re: Correct way to replace a diagram
Post by: Geert Bellekens on March 16, 2010, 07:35:16 pm
Graham,

Look for refresh/reload funtionality in (i think) the Repository class.
I'm guessing that should help in your case.

Geert
Title: Re: Correct way to replace a diagram
Post by: SomersetGraham on March 16, 2010, 09:20:54 pm
Thanks Geert
Working well now thanks

Graham