Book a Demo

Author Topic: How to access Connector labels in VB  (Read 2831 times)

beanwa

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
How to access Connector labels in VB
« on: October 16, 2018, 07:45:15 am »
Hello,

I have an EA package with about 20 diagrams in it. When I create a template I noticed that none of my connectors are brought in despite I have connectors selected (I have tried selecting nearly every box and none give me the connection info). So I started making a VB script to see if I could find the problem. I created the following DiagramScript:

sub OnDiagramScript()

   ' Get a reference to the current diagram
   dim currentDiagram as EA.Diagram
   set currentDiagram = Repository.GetCurrentDiagram()

   if not currentDiagram is nothing then
      ' Get a reference to any selected connector/objects
      dim selectedConnector as EA.Connector
      dim selectedObjects as EA.Collection
      set selectedConnector = currentDiagram.SelectedConnector
      set selectedObjects = currentDiagram.SelectedObjects

      if not selectedConnector is nothing then
         ' A connector is selected
         msgbox "The Name is: " & selectedConnector.Name
         msgbox selectedConnector.Notes
      elseif selectedObjects.Count > 0 then
         ' One or more diagram objects are selected
         msgbox "More than one selected"
      else
         ' Nothing is selected
         msgbox "Didn't work"
      end if
   else
      Session.Prompt "This script requires a diagram to be visible", promptOK
   end if

end sub

OnDiagramScript

I was using this to confirm whether or not I could access the information and this script does indeed allow me to access what I want (the connector notes). However I have two questions:
1. Why does Package.Diagram.Connector in templates not give me the information I want? Is there any way to get this via templates?
2. The selectedConnector.Name actually displays as null (this is because my company does not currently populate this). However, the label for the connector is auto populated when we insert the connector because we select it from a list of internally created exchange elements. The label has the name of the exchange element selected. I cannot find any attributes to retrieve this. Is there some way to link the GUID for the connector to the exchange element to get this information?

I am new to EA so I apologize in advance for any lack of clarity. Just ask and I would be more than happy to try to clarify.

Thanks!

beanwa

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: How to access Connector labels in VB
« Reply #1 on: October 16, 2018, 08:12:00 am »
UPDATE: The Connector GUID does not match the Exchange Element GUID that it is generated from. I am very confused as to why. Again, if anyone needs more information on this for clarity please let me know, but for company discretionary reasons I would prefer to not put unnecessary details.