Book a Demo

Author Topic: Auto layout Diagram from Visual Basic  (Read 9301 times)

Knightrider

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Auto layout Diagram from Visual Basic
« on: August 23, 2016, 09:02:52 pm »
Hi team EA

I have created about 70 component diagrams using VB scripting. After I have created the diagrams, I need the diagrams to show the components in a circle. This I can do by manually clicking on the "layout Diagram" and selecting the circle option for each diagram (Actually its not that simple as  this sometimes leaves elements hidden behind each other so I have to EDIT->Select All followed by a right click on the diagram and select Space Evenly -> Across. Then I select the Circle option and I get all the elements in a circle without any hidden ones).

My question is how do I do the circle diagram layout automatically as I don't want to go through each of the 70 diagrams manually.

Many thanks in advance.

McMannus

  • EA User
  • **
  • Posts: 108
  • Karma: +4/-1
    • View Profile
Re: Auto layout Diagram from Visual Basic
« Reply #1 on: August 23, 2016, 09:06:08 pm »
Hi Knightrider,

have a look at the Project Interface class and its layoutDiagramEx() method.

http://www.sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/project_2.html

Best Regards,
Jan
« Last Edit: August 23, 2016, 09:08:25 pm by McMannus »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Auto layout Diagram from Visual Basic
« Reply #3 on: August 23, 2016, 11:12:17 pm »
AFAIK there is no way to access the "layout tools" (Circle Box etc.) from the API.

The API only exposes the Layout Diagram functionality in the Diagram Properties.

I know this doesn't help...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Auto layout Diagram from Visual Basic
« Reply #4 on: August 23, 2016, 11:25:10 pm »
EA offers these (from the EAConstants):
Code: [Select]
// =================================================================================================
// ConstLayoutStyles
// See http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/constlayoutstylesenum.htm
// =================================================================================================
var lsDiagramDefault = 0x00000000;
var lsProgramDefault = 0xFFFFFFFF;
var lsCycleRemoveGreedy = 0x80000000;
var lsCycleRemoveDFS = 0x40000000;
var lsLayeringLongestPathSink = 0x30000000;
var lsLayeringLongestPathSource = 0x20000000;
var lsLayeringOptimalLinkLength = 0x10000000;
var lsInitializeNaive = 0x08000000;
var lsInitializeDFSOut = 0x04000000;
var lsInitializeDFSIn = 0x0C000000;
var lsCrossReduceAggressive = 0x02000000;
var lsLayoutDirectionUp = 0x00010000;
var lsLayoutDirectionDown = 0x00020000;
var lsLayoutDirectionLeft = 0x00040000;
var lsLayoutDirectionRight = 0x00080000;

q.

Knightrider

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: Auto layout Diagram from Visual Basic
« Reply #5 on: August 26, 2016, 11:12:56 pm »
Hi everyone

I've been away so didn't get a chance to say thanks for your time.

Paolo and Qwerty/McMannus, are we all talking about the same thing as there seems to be a conflict of views. When I generate a diagram from the API, all the components are bunched together on the top left hand side of a diagram. This is be cause I have not positioned the components when adding them to the diagram. I then click "Layout Diagram" which gives me the list (Circle, Ellipse, Box, Per Page, Diagraph ....). I select Circle so all the components appear in a circle with the connectors showing my flows. It is this selection of the diagram circle property I want to be able to set from the API.

Thanks again for your inputs.

McMannus

  • EA User
  • **
  • Posts: 108
  • Karma: +4/-1
    • View Profile
Re: Auto layout Diagram from Visual Basic
« Reply #6 on: August 26, 2016, 11:32:26 pm »
Long story short:

Paolo is right: You cannot programmatically access the layout types like Circle, Box, etc. you know from the UI.

The only means of performing some programmatic layout with EA is through
Code: [Select]
Project.layoutDiagramEx(string DiagramGUID, long LayoutStyle, long Iterations, long LayerSpacing, long ColumnSpacing, boolean SaveToDiagram)
where LayoutStyle is one of the Enum values qwerty posted.