Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: iwt2 on August 04, 2010, 12:04:25 am
-
Hello everyone,
I have a question:
From a Package object (a row of t_package table) I can find the Element object (a row of t_object table) associated.
But from an Element object, can I find directly the object associated Package? A database level know how to find it: if the element is of type package, I have only to look at the field PDATA1 to know the id of the associated package (Table t_package). But I need to do it with the methods of the api.
Any idea to do it directly?
Thank you very much.
-
hello iwt2,
did u try :
Repository.GetPackageByID(YourElement.PackageID) ;
?
-
hello iwt2,
did u try :
Repository.GetPackageByID(YourElement.PackageID) ;
?
that's not what I need. This instruction returns the package where the element is.
As you know, when you create a package, EA generates two records: one at the t_object table and other at the t_package table. both are related through the field PDATA1 of the t_object table.
I need to find the package (Table t_package) from element (table t_objec) using the API methods.
other idea?
-
The t_package and t_object items for the same package share the same GUID so you would use:
Repository.GetPackageByGuid(MyPackageElement.ElementGuid);
or in the other direction:
Repository.GetElementByGuid(MyPackage.PackageGuid);
HTH,
Paolo
-
For that matter, as long as you only need to read (not change) the ID, you can retrieve the PDATA1 field via the API. Element.MiscData(0) will return the contents of PDATA1.
The catch is that this is a read only value. You cannot directly manipulate the PDATA fields through the MiscData fields.
-
great! just what I needed :D.
thank you very much everybody.