Enterprise Architect: Hide only “top” labels of connectors programmatically

你。 提交于 2019-12-11 08:16:20

问题


I want to hide the "top" part of all connector labels of a diagram. For this, I tried to set up a script, but it currently hides ALL labels (also the "bottom" labels which I want to preserve):

// 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());
        }
    }
}

When I hide only the top labels manually (context menu of a connector/Visibility/Set Label Visibility), the Geometry property of the DiagramLinks remains unchanged, so I guess the detailed label visibility information must be contained somewhere else in the model.

Does anyone know how to change my script?

Thanks in advance!

EDIT: The dialog for editing the detailed label visibility looks as follows:

My goal is unchecking the "top label" checkboxes programmatically.


回答1:


In the Geometry attribute you will find a partial string like

LLT=CX=36:CY=13:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=1:DIR=0:ROT=0;

So in between LLT and the next semi-colon you need to locate the HDN=0 and replace that with HDN=1. A simple global change like above wont work. You need a wild card like in the regex LLT=([^;]+); to work correctly.



来源:https://stackoverflow.com/questions/44889397/enterprise-architect-hide-only-top-labels-of-connectors-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!