1
Automation Interface, Add-Ins and Tools / Re: Adding a package with stereotype
« on: September 28, 2009, 11:15:59 pm »
Thanks for your reply.
I tried exactly the code you suggested, but it didn't work... I guess the problem isn't really changing the stereotype, because the following code is successful in doing that. After I change the StereotypeEx and update, I can already see the new stereotype applied.
Sub InsertPackage(Root As Object, Name As String, Notes As String, Pack As Object)
Set Pack = Root.Packages.AddNew(Name, "PackageUC")
If Not Pack.Update() Then
MsgBox (Pack.GetLastError())
End If
Pack.StereotypeEx = "PackageUC"
If Not Pack.Update() Then
MsgBox (Pack.GetLastError())
End If
End Sub
The problem is that even after the stereotype is applied, the tagged values configured in the stereotype are not shown. I try to synchronize the PackageUC Stereotype in the EA application, but it doesn't work. If I insert the PackageUC element directly from EA, all the tagged values are there, but inserting it as a normal package and then trying to update to another stereotype just doesn't seem to work.
I submitted an enquiry to sparx and got the following answer:
Unfortunately, the result was the same, and even though the stereotype was modified, the tagged values related to it were not accessible... If only it was possible to insert the package with the right stereotype in the Addnew() method, maybe it would work.
I tried exactly the code you suggested, but it didn't work... I guess the problem isn't really changing the stereotype, because the following code is successful in doing that. After I change the StereotypeEx and update, I can already see the new stereotype applied.
Sub InsertPackage(Root As Object, Name As String, Notes As String, Pack As Object)
Set Pack = Root.Packages.AddNew(Name, "PackageUC")
If Not Pack.Update() Then
MsgBox (Pack.GetLastError())
End If
Pack.StereotypeEx = "PackageUC"
If Not Pack.Update() Then
MsgBox (Pack.GetLastError())
End If
End Sub
The problem is that even after the stereotype is applied, the tagged values configured in the stereotype are not shown. I try to synchronize the PackageUC Stereotype in the EA application, but it doesn't work. If I insert the PackageUC element directly from EA, all the tagged values are there, but inserting it as a normal package and then trying to update to another stereotype just doesn't seem to work.
I submitted an enquiry to sparx and got the following answer:
Quote
The Stereotype for a package must be set on it's corresponding Element object (accessed through the "Element" property on the Package element). Please note that this object is only available after performing the initial Update() call after creating a new Package. The second string parameter in the Packages.AddNew() call is not currently used.
Example:
Set p = Parent.Packages.AddNew("MyNewPackage", "")
p.Update()
p.Element.Stereotype = "PackageUC"
p.Update()
Unfortunately, the result was the same, and even though the stereotype was modified, the tagged values related to it were not accessible... If only it was possible to insert the package with the right stereotype in the Addnew() method, maybe it would work.