Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Martin Walke on May 07, 2010, 11:59:35 pm
-
Hi all,
Can anyone help me in setting the style of a diagramlink?
When I read a link's style, I get "Mode=3;EOID=424B22C5;SOID=C83E62F7;Color=-1;LWidth=0;"
I want to set the colour but a) what do the other parameters mean (the non-obvious ones) and b) do I have to set all of them or just the one I want to change.
I've tried just setting "color=255;" and doing a .Update but it doesn't seem to work.
I think I understand how the diagramlink vs connectors work but where is this info actually documented. :-?
TIA
Martin
-
Ok - exploring further, and looking at other forum posts particularly
http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1250840058, the links that I want to manipulate exist in the t_diagramlinks table but if I use the Ishidden property, it doesn't work but if I modify the EAP file directly I had hide and show the link.
Has anyone had any joy at all in manipulating the diagram links from the API?
If I use SQL injection it seems works correctly.
Is this a bug?
-
Hi Martin,
Try:
EADiagram.DiagramLinks.Delete(iEADiagramLinkIndex);
EADiagramLink.IsHidden = true;
EADiagramLink.Update();
You need to iterate through the set of DiagramLinks until you find the right one, delete it from the collections then set the IsHidden to true.
HTH,
Paolo
-
Martin,
Could you post a snippet of the code you are using to manipulate the style?
I guess you do know that you have to refresh the diagram before the changes are visible?
Geert
-
Hi guys,
My bad!
I thought I'd got this figured out but what was happening was - it was creating the links when I did a .LayoutDiagramEx call but I was trying to manipulate the links before that. :-[
However, having got that sorted and yes Geert I did realise I had to refresh the diagram ;), it doesn't show the change until I close and reopen the diagram.
Here's my
Public Function ChangeStyle(DLinkStyle As String, parameter As String, value As String) As String
Dim parms
Dim i As Integer
Dim found As Boolean
ChangeStyle = DLinkStyle
parms = Split(DLinkStyle, ";")
found = False
For i = 0 To UBound(parms) - 1
If UCase(Split(parms(i), "=")(0)) = UCase(parameter) Then
parms(i) = parameter & "=" & value
found = True
Exit For
End If
Next
If found Then ChangeStyle = Join(parms, ";")
End Function
=================================
For i = 1 To UBound(ConstraintValues)
For j = 0 To dia.DiagramLinks.Count - 1
Set dl = dia.DiagramLinks.GetAt(j)
If dl.ConnectorID = ConstraintValues(i).ConnectorID Then
dl.Style = ChangeStyle(dl.Style, "Color", "255")
dl.Update
Exit For
End If
Next
Next
getCurrentRepository.RefreshOpenDiagrams False
ConstraintValues() is simply structure array (the structure contains the ConnectorId and other info) that contains a list of those connectors that have constraints defined against them.
The whole purpose here is to show, on the diagram via colours, which connectors have constraints and which don't.
Martin
-
Hi Martin,
I'm happy you figured it out.
Nice idea to give the relations with constraints a different color, I can really see the usefulness of that.
Geert
-
Thanks Geert.
The problem sort of still exists, in that I have to close and open the diagram before I can see the coloured links. Even though I'm using RefreshOpenDiagrams what else should I be doing?
-
What happens if you change the parameter to true?
Or otherwise you could refresh each diagram separately using Repository.ReloadDiagram (long DiagramID) (allows you to only reload those diagrams that actually have been changed)
If that doesn't work you could close the diagrams with Repository.CloseDiagram (long DiagramID) and open them again with Repository.OpenDiagram (long DiagramID).
Geert
-
Perfect! Thanks Geert.
I'd already tried .RefreshOpenDiagrams True but reloading the diagram sorted it out.
Great! [smiley=thumbsup.gif]