Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: EAButNotForGames on July 16, 2024, 09:35:47 pm
-
Moin,
Does anybody know if I can create a Custom Table with the dimensions x an y via a script.
I can create a dimensionless table. But not with rows and columns.
I figured, I need to set the TaggedValues data and dataFormat, but I can't change them via script.
-
Why can't you change them with a script?
Can you show the code you are using?
Geert
-
So the code is basically:
var new_element as EA.Collection;
new_element = selectedPackage.Elements;
new_element = new_element.AddNew("A Table", "Custom Table");
new_element.TaggedValuesEx.GetAt(0).Notes = "Something" //This is the TaggedValue: data ->
new_element.TaggedValuesEx.GetAt(1).Notes = "Also Something" //This is the TaggedValue: dataFormat -> They both have a specific format, but I was to lazy to type it
new_element.Update();
I tried both Value and Notes for TaggedValue and TaggedValueEx and it didn't work.
-
You have to first get the tagged value object, then update it's value, and then save it to the database with .Update()
Element.Update() only saves the properties of the element to the database, not the properties of your tagged values.
Also, after creating an element you need to Update() it before it will have the tagged values you need.
And you'll want to create an element using the fully qualified stereotype. So something like "EAUML::Custom Table", making sure the stereotype exactly corresponds to the defined stereotype, inclusing upper/lower case.
Geert
-
Thank you very much!
This was such a simple mistake.
Also, do you by chance know, how I can access the Inital Value of a property?
-
Also, do you by chance know, how I can access the Inital Value of a property?
You can't really. That value is defined in the MDG, and not stored in the database.
Geert
-
Ah, dam.