Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: tweber 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.
-
You shouldn't assume. It's all documented
This is the connector page:
https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/connector2_2.html (https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/connector2_2.html)
And it links to this page for the property Properties: https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/properties2.html (https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/properties2.html)
Geert
-
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.
-
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 (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
-
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.
-
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 (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
-
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.
-
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
-
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.");
}
-
This works:
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
-
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.:)