Book a Demo

Author Topic: Diagram layout  (Read 5886 times)

Monsieur

  • EA User
  • **
  • Posts: 142
  • Karma: +0/-0
    • View Profile
Diagram layout
« on: March 26, 2015, 09:20:42 pm »
Hello sparxian,

Little nothing today, but couldn't find a solution:
[size=16]Can we manage diagram automaticaly in EA as you can do manually by defining the layout of a Driagram to Box or Digraph?[/size]

something like (THIS DOES NOT EXIST, i just dream about it)
          currentDiagram.Layout(Digraph)
           Repository.ReloadDiagram(currentDiagram.DiagramID)
would have been perfect :p

I saw about EA Matic, but it only manage lines no?
http://bellekens.com/2015/03/14/configure-your-own-default-line-styles-in-enterprise-architect-with-ea-matic/

I am sure there is a function but i can't find it.
Thank you

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Diagram layout
« Reply #1 on: March 26, 2015, 10:03:24 pm »
Interesting

The closest I could find is the following

LayoutDiagramEx (
string DiagramGUID,
long LayoutStyle,
long Iterations,
long LayerSpacing,
long ColumnSpacing,
boolean SaveToDiagram
)


this method is defined in the Project class

This may partially address what you are looking for

Phil
Models are great!
Correct models are even greater!

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Diagram layout
« Reply #2 on: March 26, 2015, 10:09:46 pm »
Follow up post, the method LayoutDiagramEx appears to use the Digraph style

Phil

Models are great!
Correct models are even greater!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram layout
« Reply #3 on: March 26, 2015, 11:04:44 pm »
In one of the other examples: Self-maintaining diagrams in Enterprise Architect with EA-Matic I use automatic layout of diagram using this code below:

Code: [Select]
'layout the auto diagram
function layoutAutoDiagram(diagramID, model)
    dim diagram
    set diagram = model.getDiagramByID(DiagramID)
    'if the diagram is an auto diagram then we do an automatic layout
    if Left(diagram.name,LEN("AUTO_")) = "AUTO_" then
        'auto layout diagram
        dim diagramGUIDXml
        'The project interface needs GUID's in XML format, so we need to convert first.
        diagramGUIDXml = Repository.GetProjectInterface().GUIDtoXML(diagram.wrappedDiagram.DiagramGUID)
        'Then call the layout operation
        Repository.GetProjectInterface().LayoutDiagramEx diagramGUIDXml, lsDiagramDefault, 4, 20 , 20, false
    end if
end function

Geert

Monsieur

  • EA User
  • **
  • Posts: 142
  • Karma: +0/-0
    • View Profile
Re: Diagram layout
« Reply #4 on: March 27, 2015, 07:18:55 pm »
Well, thank you both!

I must look deeper into that LayoutDiagramEx function (which seem to be the only solution (but it seem a bit harsh to apprehend).

@Geert Bellekens
I 'll give a try to your function Geert (by including it into a Library and calling it). I'll give you some feedback about it. Thanks for giving pieces of your code so kindly.

Sparxians are the best  ;D

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Diagram layout
« Reply #5 on: March 27, 2015, 07:25:30 pm »
Quote
Sparxians are the best  ;D

To avoid confusion, we usually use the term "Sparxians" to denote employees of Sparx Systems.

Neither Phil nor myself are employed by Sparx Systems, although we both work for a Sparx Systems partner.

You can recognize actual Sparxians by the red color of their name (Simon, RoyC, KP,...)

Geert

Monsieur

  • EA User
  • **
  • Posts: 142
  • Karma: +0/-0
    • View Profile
Re: Diagram layout
« Reply #6 on: March 27, 2015, 07:38:45 pm »
Hum sorry for my vocabulary mistake, thanks for pointing that out!

[size=18]Sparx community*[/size] is the [size=18]BEST[/size][/b]

 ;)  ;)  ;D  ;)  :D

Monsieur

  • EA User
  • **
  • Posts: 142
  • Karma: +0/-0
    • View Profile
Re: Diagram layout
« Reply #7 on: March 27, 2015, 09:16:36 pm »
So many functions i dont know!!!!

Some feedback.
Code: [Select]
'layout the auto diagram
function layoutAutoDiagram(diagramID, model) //[color=#0000ff]model is Repository ?[/color]
   dim diagram
   set diagram = model.getDiagramByID(DiagramID)
   'if the diagram is an auto diagram then we do an automatic layout
   if Left(diagram.name,LEN("AUTO_")) = "AUTO_" then
        'auto layout diagram
        dim diagramGUIDXml
        'The project interface needs GUID's in XML format, so we need to convert first.
        diagramGUIDXml = Repository.GetProjectInterface().GUIDtoXML(diagram.wrappedDiagram.DiagramGUID) [color=#0000ff]//wrappedDiagram? is that a real thing :p?[/color]
        'Then call the layout operation
        Repository.GetProjectInterface().LayoutDiagramEx diagramGUIDXml, lsDiagramDefault, 4, 20 , 20, false
   end if
end function


A normal GUID is like {B303A097-298B-4e59-8261-225E63C3AC19}, what should look like an XML guid? <GUID>B303A097-298B-4e59-8261-225E63C3AC19</GUID>??

EDIT: Okay found out.
Here is my solution (in JS):
Code: [Select]
var currentDiagram as EA.Diagram;
currentDiagram = Repository.GetCurrentDiagram();
var diagramGUIDXml
diagramGUIDXml = Repository.GetProjectInterface().GUIDtoXML(currentDiagram.DiagramGUID)
Repository.GetProjectInterface().LayoutDiagramEx(diagramGUIDXml, lsDiagramDefault, 4, 20 , 20, false);


It does not work perfectly, but it's better and i don't know how to solve the problem... It's still not as good as Layout Box or Layout Digraph.......  :'( :'( :'( :'(