Author Topic: Connector Properties  (Read 2418 times)

tweber

  • EA User
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Connector Properties
« on: September 06, 2024, 10:12:47 pm »
in the EA.Connector type, there's an attribute, Properties.  I'm assuming it's a collection, but have not been able to map it to a specific EA element  (there's no EA.Property that I can see).  TIA for any help.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector Properties
« Reply #1 on: September 06, 2024, 10:26:21 pm »

tweber

  • EA User
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Connector Properties
« Reply #2 on: September 06, 2024, 10:58:57 pm »
THanks, Geert.  I found that information.  My issue is that while the EA.Connector has a Properties attribute, which I assume is an EA.Collection, I haven't been able to find an EA.xxxxx that each item in the collection maps to.  There's no EA.Property.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector Properties
« Reply #3 on: September 06, 2024, 11:14:11 pm »
THanks, Geert.  I found that information.  My issue is that while the EA.Connector has a Properties attribute, which I assume is an EA.Collection, I haven't been able to find an EA.xxxxx that each item in the collection maps to.  There's no EA.Property.
I posted the second link as well didn't I https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/properties2.html

There is no EA.Collection, and you shouldn't assumer there is. You can use this object using the Item() method. That method return a Property object/structure that has it's attributes documented on this same page as well.

Geert

tweber

  • EA User
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Connector Properties
« Reply #4 on: September 07, 2024, 12:11:55 am »
in jscript (and I assume in vbscript as well), I can create a declaration "var coll as EA.Collection;", which is an array with methods, one of which is "coll.GetAt()", which will return an element of that collection (I'm sure you know all of this).  My issue is that while the connector (i.e., EA.Connector) has an element called "Properties", which appears to be a collection, as I can retrieve properties.Count. However, I've not found what element it is a collection of.  In your second link, there's a Property class.  In jscript, I can't create a 'Property' using "var prop as EA.Property".  EA.Property doesn't appear to exist.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector Properties
« Reply #5 on: September 07, 2024, 06:47:02 am »
in jscript (and I assume in vbscript as well), I can create a declaration "var coll as EA.Collection;", which is an array with methods, one of which is "coll.GetAt()", which will return an element of that collection (I'm sure you know all of this).  My issue is that while the connector (i.e., EA.Connector) has an element called "Properties", which appears to be a collection, as I can retrieve properties.Count. However, I've not found what element it is a collection of.  In your second link, there's a Property class.  In jscript, I can't create a 'Property' using "var prop as EA.Property".  EA.Property doesn't appear to exist.
I'm not sure in how many ways I can repeat the same thing. EA.Connector.Propertis is NOT an EA.Collection. It is an EA.Properties class documented here: https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/properties2.html
It's not because it has a property called Count that it's a EA.Collection.

Geert

tweber

  • EA User
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Connector Properties
« Reply #6 on: September 09, 2024, 10:05:45 pm »
It's possible that in VBScript, EA.Properties exists.  In JScript, it doesn't.  I can see conn.Properties within JScript, but cannot access it.  In fact, it appears to have the same attributes as an EA.Element when I use JScript's autofill.  I will also reiterate that in JScript, there's no EA.Property that I can map one of the conn.Properties to.  And yes, I've seen both Properties and Property in the manual.  I just can't extract anything from them.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector Properties
« Reply #7 on: September 10, 2024, 12:06:06 am »
It's possible that in VBScript, EA.Properties exists.  In JScript, it doesn't.  I can see conn.Properties within JScript, but cannot access it.  In fact, it appears to have the same attributes as an EA.Element when I use JScript's autofill.  I will also reiterate that in JScript, there's no EA.Property that I can map one of the conn.Properties to.  And yes, I've seen both Properties and Property in the manual.  I just can't extract anything from them.
There's only one API for both Jscript and VBScript (and C# and Python, and...)

Can you post the code you are using and indicate where it goes wrong?

Geert

tweber

  • EA User
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Connector Properties
« Reply #8 on: September 10, 2024, 12:46:48 am »
Here it is:

function dumpConnectorInfo() {
                var elem                                                                              as EA.Element;
                var conn                                                                              as EA.Connector;
                var selectedObjects                                     as EA.Collection;
                var diagObj                                                                        as EA.DiagramObject;
                var conns                                                                            as EA.Collection;
                var diag                                                                                as EA.Diagram;
                var props                                                                             as EA.Properties;           // <--- no such EA element exists
                var prop                                                                               as EA.Property;                               // <-- no such EA element exists
               
                Repository.EnsureOutputVisible("Script");//opens the output window
                Repository.ClearOutput("Script"); // clears the output window
               
                diag                                                                                       = Repository.GetCurrentDiagram();
                selectedObjects = diag.SelectedObjects();
                if(selectedObjects.Count > 0) {
                                for(var i = 0; i < selectedObjects.Count; i++) {
                                                diagObj                                                                                               = selectedObjects.GetAt(i);
                                                elem                                                                                     = Repository.getElementByID(diagObj.ElementID);
                                                conns                                                                                   = elem.Connectors;
                                                if(conns.Count > 0) {
                                                                for(var j = 0; j < conns.Count; j++) {
                                                                                conn                                                     = conns.GetAt(j);
                                                                                Session.Output("conn name " + conn.Name );
                                                                                Session.Output("   objType " + conn.ObjectType );
                                                                                Session.Output("   stereo " + conn.Stereotype );
                                                                                Session.Output("   metaType " + conn.MetaType );
                                                                                conn.Properties;
                                                                                if(conn.Properties.Count > 0) {                                                // this does exist
                                                                                                for(var k = 0; k < conn.Properties.Count; k++) {
                                                                                                                Session.Output(" prop name " + conn.Properties.Name);  // << this breaks also
                                                                                                }
                                                                                }
                                                                }
                                                }
                                }
                }
                Session.Output("Done.");
}                                                                             


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13251
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector Properties
« Reply #9 on: September 10, 2024, 01:33:47 am »
This works:

Code: [Select]
function main()
{
var conn as EA.Connector;

conn = Repository.GetConnectorByGuid("{3410D31C-97AA-4b70-AB0A-469C637B67C0}")
Session.Output("conn name " + conn.Name );
Session.Output("   objType " + conn.ObjectType );
Session.Output("   stereo " + conn.Stereotype );
Session.Output("   metaType " + conn.MetaType );
conn.Properties;
if(conn.Properties.Count > 0)
{                                                // this does exist
for(var k = 0; k < conn.Properties.Count; k++)
{
Session.Output(" prop name " + conn.Properties.Item(k).Name);
Session.Output(" prop Value " + conn.Properties.Item(k).Value);
Session.Output(" prop Type " + conn.Properties.Item(k).Type );
Session.Output(" prop Validation " + conn.Properties.Item(k).Validation );
}
}
}
main();

Geert

tweber

  • EA User
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Connector Properties
« Reply #10 on: September 10, 2024, 10:05:57 pm »
Thanks, Geert.  I was able to access Properties that way. And, you were correct in indicating that the info is quite carefully hidden in plain sight in the manual.:)