Book a Demo

Author Topic: How to Make Auto-generated connectors visible  (Read 3483 times)

tim-southerland

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
How to Make Auto-generated connectors visible
« on: September 25, 2010, 06:11:11 am »
I created a .vbs script that reads a .cvs and auto-generates elements and connectors.  I can see the elements in the auto generated diagram, but I can't see the connectors.    The connectors appear to be associated with the model because I can view them in the "Traceability" view, but I can't see them in the diagram.

What is the proper way to auto-generate connectors that are VISIBLE?

The code I used to autogenerate connectors & connected elements was:

Code: [Select]

dim source as ea.element
dim target as ea.element
dim connector as ea.connector

set source = testpackage.elements.AddNew ("sender","Activity")
source.update()
set target= testpackage.elements.AddNew ("rcvr","Activity")
target.update()
set v_connector= testpackage.Connectors.AddNew ("Test Connection","Association")

v_connector.SupplierID = target.ElementID
v_connector.ClientID = source.ElementID

v_connector.update()
source.connectors.refresh()


stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: How to Make Auto-generated connectors visible
« Reply #1 on: September 25, 2010, 06:23:55 am »
thats how i create connectors:
possible error of yours can be the missing diagram id of the connector


targetElement is the Element from which the connector goes to the element activity
actdiag is the diagram where the connector should be added.
Code: [Select]
EA.Connector con = (EA.Connector)targetElement.Connectors.AddNew("", "ControlFlow");
            con.DiagramID = actDiag.DiagramID;
            con.SupplierID = activity.ElementID;
            con.Update();

stao

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to Make Auto-generated connectors visible
« Reply #2 on: September 27, 2010, 03:27:13 pm »
The diagramID shouldn't matter at all. (except maybe for "sequence" links)
Tim, can you verify that the connectors actually exist in the links tab of the source or target properties?
If they are there they should show up on any diagram that contains both source and target.
However, they will only show up when you have reloaded those diagrams.
The Repository object contains some operations to reload the diagrams, so that might help.

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to Make Auto-generated connectors visible
« Reply #3 on: September 27, 2010, 03:31:54 pm »
Having another look at your code revealed the error.
You are adding the relationship to the package connectors collection, whereas you should add it to the source or targets connectors.
Something like this should work:

Code: [Select]

dim source as ea.element
dim target as ea.element
dim connector as ea.connector

set source = testpackage.elements.AddNew ("sender","Activity")
source.update()
set target= testpackage.elements.AddNew ("rcvr","Activity")
target.update()
set v_connector= source.Connectors.AddNew ("Test Connection","Association")

v_connector.SupplierID = target.ElementID

v_connector.update()
// source.connectors.refresh() // refresh only necesarry if you will be doing something with the connectors collection later on in the code.


And remember to reload the diagrams if they are already open.

Geert