Book a Demo

Author Topic: Connecor RouteStyle  (Read 6576 times)

Dumller

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Connecor RouteStyle
« on: March 25, 2011, 12:17:56 am »
I have built an add-in to generate class diagrams. I want the connectors to to have the "Direct" line style but they are always getting created as "Custom Line". I am assuming the Connector.RouteStyle can be used to control this but the values are not documented anywhere I can find.

Here is how I am creating the connectors:

// Add the connector and set the supplier
EA.Connector newConnector = EA.Connector)client.Connectors.AddNew("", ConnectorTypes.DEPENDENCY);
if (newConnector != null)
{
  newConnector.SupplierID = connector.SupplierID;
  newConnector.DiagramID = aClassDiagram.DiagramID;
  newConnector.RouteStyle = 1;
  newConnector.Update();
}

client.Connectors.Refresh();

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connecor RouteStyle
« Reply #1 on: March 28, 2011, 02:40:12 pm »
See http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1215385275/0#0
I think the routestyle on the connector itself is only used as a default for new connectors on diagrams.

Geert

Dumller

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Connecor RouteStyle
« Reply #2 on: March 30, 2011, 12:34:08 am »
I wrote some test code to iterate through connectors and dynamic links on a class diagram to figure out the line style. A diagram link must be created for the connector with the Style property set to one of the following:
Direct - "Mode=1"
Auto Routing - "Mode=2"
Custom - "Mode=3"

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Connecor RouteStyle
« Reply #3 on: April 01, 2011, 11:00:22 pm »
You have the right idea. You definitely have to set the style up for each connector. And to do that you must explicitly set up a diagram link if there is not one already. You should play around with horizontal and vertical tree connectors (and any other 'exotic' styles you can think of) to see if a second parameter is used in these cases. [I just don't remember off hand.]

Geert is also correct - no surprise there! - about EA using a default style for new connectors. I am not sure if EA takes the default from the diagram or from a global default; it may do both depending on how the connector is created. [Once again I don't remember, and I do not have an automation project open just now.]

If you are interested in the mechanics (and a 'gotcha' or two) then read on. Otherwise you have your answer.

David

[What follows is pretty long winded, but it will walk you through some process steps.]

There are two ways a connector - note that I did not say "link" - can be added to a diagram. The user can add one by creating a connector. In this case EA will use the default (whichever one) style. In this case EA will add a diagram link with the default style (or may leave the mode out altogether). If the user changes the connector style then EA will update (or create if necessary) the mode value for the diagram link.

Connectors are also added by EA 'on the fly' as a diagram is rendered. As the diagram is being set up EA searches for all connectors between elements that are shown on the diagram. For each of these connectors EA looks for a diagram link with the correct diagram ID. If the link is found EA uses the style (and any other) information to set up the link.

Sometimes no such link is found. Examples include: a new diagram where elements are dragged from the project browser, or an older diagram that includes elements that have since had connectors added (perhaps on some other diagram). In these cases EA 'magically' creates a diagram link using default values and renders it on the diagram. Once again I cannot remember if the default for connector style is taken from the diagram or the global default. Perhaps the diagram overrides the global default, but only if a diagram default has been explicitly defined. [There is a possible exception to the above case. EA might not do the above 'magic' if the diagram is locked. You may want to check this yourself.]

The important thing to remember is EA does not store these 'on the fly' diagram links in the model database. They are created and rendered each time a diagram is built. This can affect you in several ways. If you add connectors to a model you may find early diagrams suddenly have new links when you reopen them. This can affect early diagrams that you thought were stable. These links will not necessarily obey the formatting you have set up elsewhere on the diagram. For some diagrams (e.g. conceptual overviews, or non-technical presentation material) you may not want these links at all. In these cases you will have to go back and explicitly create diagram links for the 'new' connectors on each affected diagram, then update the appropriate values.

You can do this via the UI by setting some (any) value for the connector (the connector style is a good one to use). This causes a diagram link to be added to the model. Even if you reset the value the link remains.

With automation you need to search the model for connectors where both ends are elements on the diagram, then check for diagram links that reference both the connector ID and the diagram ID. If no such link is found you have to create one from scratch. Set the values as you require and save the link.

If you do not want these 'on the fly' links to show on a diagram, you have to follow the above instructions and then set the link to be hidden. This is a useful function to have in an automation project.

HTH, David
No, you can't have it!

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Connecor RouteStyle
« Reply #4 on: April 04, 2011, 09:13:13 am »
Just FYI - there was a change made in the release of EA 8.0 that should now make all EA.DiagramLink objects accessible via automation, including the 'on the fly' links as you call them that haven't necessarily been 'saved' to the database yet.

The Diagram.DiagramLinks collection should now always contain references to all connectors currently visible (or explicitly hidden) on the diagram.

From the release notes for EA 8.0 build 855 -
Quote
Diagram.DiagramLinks - Now includes connectors that haven't yet been saved on the diagram.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connecor RouteStyle
« Reply #5 on: April 05, 2011, 01:21:32 pm »
Quote
Just FYI - there was a change made in the release of EA 8.0 that should now make all EA.DiagramLink objects accessible via automation, including the 'on the fly' links as you call them that haven't necessarily been 'saved' to the database yet.

The Diagram.DiagramLinks collection should now always contain references to all connectors currently visible (or explicitly hidden) on the diagram.

From the release notes for EA 8.0 build 855 -
Quote
Diagram.DiagramLinks - Now includes connectors that haven't yet been saved on the diagram.

That is indeed a nice improvement. I'm sure it will save a lot of people a lot of headache in the future ;D

Geert