Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: rothnic on August 29, 2013, 04:26:41 pm
-
Finally got around to dealing with the issue of not being able to quickly change line styles to anything I want. I put together this script using JScript that you can configure to convert all lines on the current diagram to any of the available styles. I figured it may be useful to others as well, so posted it via pastebin below.
It is available through the right click menu when in a diagram. I put it together this way because I was hoping to be able to use the prompt box, but can't find any way to do that besides just an "ok" prompt. Is that documentation somewhere?
For now, you can copy it over and over for each line type. It might be a bit messy since all of the logic to move back and forth between any line style, without affecting your current work or styles is in mostly one function.
[size=12]Script Can be Copied From Here:[/size] http://pastebin.com/1MKrf1CH
(http://i.imgur.com/wDR0Cdxl.png)
(http://i.imgur.com/iVo65P7l.png)
(http://i.imgur.com/b3THvf9l.png)
-
Cool,
I added a function to one of my add-ins to do the same thing (but only limited to linestyle orthogonal square).
Here the important bit of code:
/// <summary>
/// set all links to (orthogonal - square)
/// To do se we need to set Mode=3 and TREE=OS in the style of the diagramlinks
/// </summary>
public void setLinkStyles()
{
bool updated = false;
foreach (EA.DiagramLink link in this.wrappedDiagram.DiagramLinks)
{
string linkStyle = link.Style;
//updated mode to 3
if (linkStyle.Contains("Mode="))
{
int modeBegin = linkStyle.IndexOf("Mode=") + "Mode=".Length;
string mode = linkStyle.Substring(modeBegin,1);
if (mode != "3")
{
linkStyle = linkStyle.Replace("Mode=" + mode,"Mode=3");
}
}
else
{
linkStyle = "Mode=3;"+linkStyle;
}
//update style to OS
if (linkStyle.Contains("TREE="))
{
int modeBegin = linkStyle.IndexOf("TREE=") + "TREE=".Length;
string treeStyle = linkStyle.Substring(modeBegin, 2);
if (treeStyle != "OS")
{
linkStyle = linkStyle.Replace("TREE=" + treeStyle, "TREE=OS");
}
}
else
{
linkStyle = linkStyle + "TREE=OS;" ;
}
//only need to save the link when we have actually updated its style.
if (link.Style != linkStyle)
{
link.Style = linkStyle;
link.Update();
updated = true;
}
}
//reload the diagram if we updated it.
if (updated)
{
this.model.getWrappedModel().ReloadDiagram(this.wrappedDiagram.DiagramID);
}
}
Geert
-
Yeah I put it together for the same purpose, and it is fairly simple in that case. I think you don't even need to set the mode. It gets messier trying to not lose existing formatting, and setting mode and tree, and sometimes removing tree from the style. I need to go back and clean it up.
My key limitation is using government computers, where no one is given access to adding registry values, so i could use an add-in.
Is there anyway to provide a popup of some kind via scripting, that allows user entry, or selection? I could find no documentation on the use of Session.Prompt.
-
I'm not sure (since I don't use scripting) but I think I've seen some topics go by that suggested it should be possible somehow.
Have you tried searching the forum (using the top left search button)
Geert
-
I'm not sure (since I don't use scripting) but I think I've seen some topics go by that suggested it should be possible somehow.
Have you tried searching the forum (using the top left search button)
Geert
Yeah, just tried the one on the left side. I've also checked in all the help documentation, and checked online thinking it might be something pulled from Microsoft. Nothing about Session, or PromptType.
Sparx shows in the recent tutorial video how to connect scripting and the UI modeling portion of EA. But I think that has to be in the context of a simulation.
It would be kind of neat if you could connect the scripting capability with the UI modeling because you could recreate a portion of the add-in capability in that way.
-
Hi,
may be my Addin in the community will help you:
http://community.sparxsystems.com/community-resources/745-toolset-to-set-linestyle-quick-search-and-a-lot-more
You just have to select
- Diagram
- Diagram element(s)
- Diagram link
and click on the wanted line style.
The new is that there is no need to go a long way by context, extensions,.. If you choose the wrong line style: No problem, try another one. The selection is preserved.
Helmut
-
Hi,
may be my Addin in the community will help you:
http://community.sparxsystems.com/community-resources/745-toolset-to-set-linestyle-quick-search-and-a-lot-more
You just have to select
- Diagram
- Diagram element(s)
- Diagram link
and click on the wanted line style.
The new is that there is no need to go a long way by context, extensions,.. If you choose the wrong line style: No problem, try another one. The selection is preserved.
Helmut
Thanks, yeah something like that is ideal. Unfortunately at work we can only install "approved" and tested applications, and only administrators can do it. So, I cannot use add-ins at all and can only do it via scripting.
-
Hi,
I know of this restrictions. Happily I mostly have local administration rights.
It's possible to set line style by script. In the forum you find good solutions.
With this addin it's just a click. With scripts it's some clicks.
Thanks for your response,
Helmut