Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Stenvang on April 01, 2015, 02:13:40 am
-
I'm trying to add an Element to a newly created package from code.
My code is as following and it breaks at the Element AddNew and throws an error saying "Invalid Type".
packageName = "Requirements";
Package requirementPackage = parentpackage.Packages.AddNew(packageName, "Package");
requirementPackage.Update();
if (requirementPackage != null)
{
foreach (string elementName in ElementList)
{
Element myElement = requirementPackage.Elements.AddNew(elementName, "Element"); //Breaks here
myElement.Update();
}
}
Creating the package is no problem but that other error doesn't make sense to me.
Have I misunderstood something?
-
"Element" is not a valid Element type.
Check the documentation on EA.Element. There a complete list of all accepted element types.
Geert
-
Usually I don't plug my books directly, but you might save a bit of your time when reading/exercising my Scripting book.
q.