1
votes

I have a JScript in Enterprise Architect which should hide some connector labels by setting the "HDN" attribute of the geometry property of the DiagramLinks to 1 according to https://stackoverflow.com/a/28810123:

// Get a reference to the current diagram
var currentDiagram as EA.Diagram;
currentDiagram = Repository.GetCurrentDiagram();

if (currentDiagram != null)
{
    for (var i = 0; i < currentDiagram.DiagramLinks.Count; i++)
    {
        var currentDiagramLink as EA.DiagramLink;
        currentDiagramLink = currentDiagram.DiagramLinks.GetAt(i);

        currentDiagramLink.Geometry = currentDiagramLink.Geometry
            .replace(/HDN=0/g, "HDN=1")
            .replace(/LLT=;/, "LLT=HDN=1;")
            .replace(/LRT=;/, "LRT=HDN=1;");
        if (!currentDiagramLink.Update())
        {
            Session.Output(currentDiagramLink.GetLastError());
        }
    }
}

However, the diagram is not updated (the view does not change). Am I missing something?

When executing the script a second time, I can see in the debugger, that the new Geometry values are still there, but they don't seem to get applied.

1

1 Answers

2
votes

Diagrams do not get updated on any element change (well, usually and in most cases; this is EA). You need to reload changed diagrams with

Repository.ReloadDiagram (currentDiagram.DiagramID);