Book a Demo

Author Topic: Diagram Properties  (Read 3679 times)

Doug Blake

  • EA User
  • **
  • Posts: 102
  • Karma: +0/-0
    • View Profile
Diagram Properties
« on: November 22, 2013, 03:38:58 am »
I have a couple of hundred diagrams that I want to change properties for.
Use Alias if Available and Show Namespace.
I have exported the package but when I change one parameter, more than 1 part of the XML code is changed. Does anyone know what I need to change? I think the Alias one is easy, but the Namespace one eludes me.

Of course it would be better if I could select all the diagrams and do it in one go, but thats Sparx for you.
DGB Using 12.0.1214 / eaDocX 3.6.2.1 / MSSQL / TFS / Windows 7 / IE11

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Diagram Properties
« Reply #1 on: November 22, 2013, 09:37:41 am »
You need to write a script that adds/changes Diagram.ExtendedStyle so it contains
Code: [Select]
UseAlias=1;Also you need to t_diagram.ShowForeign to 0 (IIRC you can only do that in the table and not via API).

q.

Stefan Bolleininger

  • EA User
  • **
  • Posts: 308
  • Karma: +0/-0
    • View Profile
Re: Diagram Properties
« Reply #2 on: November 22, 2013, 08:04:51 pm »
For the Namespace you may do it with a script to iterate through your package and change all diagrams.

Something like that: ( I copied it from my project and use the Fully qualified name, not only the Namespace).

Code: [Select]
EA.Diagram ndiagram = null;

                EA.EventProperty newdiagram = (EA.EventProperty)info.Get("DiagramID");
                ndiagram = repository.GetDiagramByID(int.Parse(newdiagram.Value.ToString()));


            string olddiagramtags = ENARTalis_main.delxml(repository.SQLQuery("Select StyleEx from t_diagram WHERE Diagram_ID=" + ndiagram.DiagramID + ""));
            if (diagram_showFQN == true) // Fully qualified name
            {
                 string olddiagramtags2 = ENARTalis_main.delxml(repository.SQLQuery("Select StyleEx from t_diagram WHERE Diagram_ID=" + ndiagram.DiagramID + ""));
                 if (olddiagramtags2.Length >= 10)
                 {
                     if (olddiagramtags2.Contains("ShowFQN=1;"))
                     {
                         //Do nothing
                     }
                     else if (olddiagramtags2.Contains("ShowFQN=0;"))
                     {
                         //string zerlegen und showFQN=1 einsetzen
                         string[] diaspilt = olddiagramtags2.Split(new string[] { "ShowFQN=0;" }, StringSplitOptions.None);
                         string olddt = diaspilt[0] + "ShowFQN=1;" + diaspilt[1];
                         repository.Execute("Update t_diagram SET StyleEx='" + olddt + "' WHERE Diagram_ID=" + ndiagram.DiagramID + "");
                     }
                     else
                     {
                         //Add FQN
                         string olddt = olddiagramtags2 + "ShowFQN=1;";
                         repository.Execute("Update t_diagram SET StyleEx='" + olddt + "' WHERE Diagram_ID=" + ndiagram.DiagramID + "");
                     }
                 }
            }

Unfortunately I haven't seen a way to do it with the correct API.

Regards

Stefan
Enterprise Architect in "safetycritical development" like medical device industry. My free Add-in at my Website