Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: semo on October 21, 2015, 08:27:20 pm
-
Hi,
Is it possible to hide source and target roles of a connector using scripting? (roles for a certain connector would be hidden on all diagrams)
I.e. what you can do manually through: on connector, right-click / visibility / set label visibility
We would like to have the roles visible in the relations pane, but don’t want to make the diagrams too overloaded…
Any ideas?
-
Yes it is possible.
But it will require some nasty string manipulation and usage of the infamous Repository.Execute
I don't remember exactly where this info is stored, but I think it has been mentioned here on the forum in the past.
Make sure to use the top left search button and check all search parameters.
Geert
-
The answers were always using shape script to suppress the label. I'll see if I can find anything else.
q.
-
You need (as Geert pointed out) use Repository.Execute o manipulate t_diagramlinks.geometry (maybe you can do that through API too, but I'm not sure about that). Anyhow, you have to foster that string for
<lbl>=<value>;
where <lbl> is any of LLT (top), LMT (mid) or LMB (bottom label) and <value> is a string not containing a semicolon (as regex "\$LLB=([^;]+);"
). Now inside that string scan for HDN=<val>;
where <val> is 1 (hidden) or 0 (not hidden) and change that to your needs. Eventually you have to add an according LLT/LMT/LMB value with "HDN=1;".
q.
-
Thanks for the answers! I'll have to play around a bit to see if I can it to work - but at least I know where I need to look :-)
I'll let you know the outcome (might be a few days).
-
You need (as Geert pointed out) use Repository.Execute o manipulate t_diagramlinks.geometry (maybe you can do that through API too, but I'm not sure about that). Anyhow, you have to foster that string for
<lbl>=<value>;
where <lbl> is any of LLT (top), LMT (mid) or LMB (bottom label) and <value> is a string not containing a semicolon (as regex "\$LLB=([^;]+);"
). Now inside that string scan for HDN=<val>;
where <val> is 1 (hidden) or 0 (not hidden) and change that to your needs. Eventually you have to add an according LLT/LMT/LMB value with "HDN=1;".
q.
It doesn't get any nastier then this ;D
Geert
-
The whole link geometry is nasty. A long while ago I posted a script on how the label information can be changed -> http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1398959952/9#9.
I also wrote an antlr grammar to parse the whole thing so I could pretty print the entire field after pulling it from t_diagramlinks.geometry. This helped me understand the changes I needed to make to the script for specific purposes. The grammar took a while to develop because the usage of the field appears to have changed over the years. I used repositories created from version 7 onwards to identify possible tokens and variations.
If the grammar might help let me know and I'll post the source. Using antlr it can be used to generate source code for all the languages antlr supports.
Stan.
-
Sounds a bit like overkill to throw it into a compiler where a simple regex will suffice.
q.
-
Sounds a bit like overkill to throw it into a compiler where a simple regex will suffice.
Depends on need.
I'd like to see a Regex that can interpret every variation of this field and separate it into intelligible groups for further work. For simply finding specific text that needs to be updated and replaced a regex works.
-
A shot from the hip: "(LLT|LMT|LMB)=([^;]);" to find the 3 label descriptions and then a simple split by ":" for the 2nd group which will deliver "(.+)=(.+)" groups where you can make a case for the first group and evaluate the 2nd as parameter value.
q.
-
LLT|LLB|LMT|LMB|LRT|LRB|IRHS|ILHS
;)
-
Ah yes. There are more label positions.
q.