Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Alin Dobre on July 15, 2009, 04:17:08 am
-
Can we set Package.TaggedValues with the automation interface? I was looking through the API and found nothing on it; and I tried it and it didn't work. Is it something I did or is it not supported?
Here is the code that i used:
EA.TaggedValue package_value = (EA.TaggedValue)package.TaggedValues.AddNew("Id", "");
Thanks in Advance,
Alin
-
Every Package object (with the exception of the root model node) has an associated Element object accessible through the Package.Element property. You will need to assign the Tags to the TaggedValues collection on the Element object.
Example:
EA.TaggedValue tag = (EA.TaggedValue)package.Element.TaggedValues.AddNew("Id", "");
tag.Value = "1";
tag.Update();
-
Every Package object (with the exception of the root model node) has an associated Element object accessible through the Package.Element property. You will need to assign the Tags to the TaggedValues collection on the Element object.
Example:
EA.TaggedValue tag = (EA.TaggedValue)package.Element.TaggedValues.AddNew("Id", "");
tag.Value = "1";
tag.Update();
Yes thank-you, but how do you add a tagged value to the Package itself, not the element within that package?
Using the automation interface.
Regards,
Alin
-
Aaron,
EA.TaggedValue package_taggedID = (EA.TaggedValue)package.TaggedValues.AddNew("Id", "");
this would logically create a tagged value for the package, but it does not work cause package does not support it, is there any other way?
Regards,
Alin
-
Yes thank-you, but how do you add a tagged value to the Package itself, not the element within that package?
It's not adding tagged values to an element contained by that package. Each package is represented by an element that contains all the general element properties. This is where Aaron's example is adding a tagged value.
-
If you've got the latest build of EA (846) there is an example VB Script included which illustrates how to set a Package's stereotype. See VBScript - Manage Packages Example.vbs: lines 42 - 47.
Alternatively, if you check the Java Example (%EA_INSTALL_DIR%\Code Samples\Java_Sample\src) there is a Java implementation of the same example. See ManagePackagesExample.java: lines 78 - 82.
-
At the risk of an unnecessary repetition...
The way EA handles packages is something you have to get used to, but it makes good sense. There are two 'parts' (for lack of a better word) that cooperate to provide Package functionality. Note that what goes in which part is sometimes a judgment call; Sparx did a pretty good job here but you may have to check the documentation from time to time. Here's how they handle Package capabilities.
Things that are particular to package, including hierarchies of 'inner' packages and such, are features (attributes and methods) of the Package class. This is how you've been handling packages so far. No need to change anything.
Things that are common to all (or most) elements in UML are handled a different way. This sort of thing includes the collection of tagged values, as well as other common properties and methods. In these cases the Package class works like any other Element in EA; Sparx handled this by exposing the 'inner Element' of the Package class, and using that to provide these features.
You will find an Element property of the Package class; this returns an Object that can be cast to type "EA.Element" to your program. This Element is not a 'contained' element, and does not appear in the Elements list of the Package. It is the Package itself! [Check the GUID and you'll see that it matches that of the Package.]
When you need to work with element-like features of the Package class, you access these through the Element property. In your case you would obtain the Element reference via the property, then use AddNew to create the tagged value. Something like
EA.Element packElem = (EA.Element)myPack.Element;
EA.TaggedValue tv = (EA.TaggedValue)packElem.TaggedValues.AddNew("Id","");
...and so on. [Please forgive if I got the punctuation wrong, I'm in a hurry.]
HTH, David
-
Is there an updated SDK for build 846? And where can I find it in PDF form?
Regards,
Alin
-
Or is there a changlist for build 846?
Thanks,
Alin Dobre
-
The change list is at http://www.sparxsystems.com/products/ea/history.html#846
-
Thank-You very much Simon.
Regards,
Alin Dobre
-
Release Notes for build 846: [EDIT: Ahhh - Simon got there while I was checking things out for this reply!]
http://www.sparxsystems.com/products/ea/history.html#846
The SDK forms part of the documentation integrated with the product (click on the Help | Help Contents menu option) - it is the second-to-last main topic.
There is a pdf version of the Help on:
http://sparxsystems.com/bin/EAUserGuide.pdf
We also provide separate pdf documents for each of the main topics (and a couple of the second-level topics) on the Resource Documents web page. HOWEVER, we are working on mechanisms for streamlining the more frequent update of these pdfs, and as these mechanisms are not yet in place, the Resource Documents (and web Help) currently are not updated for the minor releases.
-
Thanks again Admins
Regards,
Alin Dobre