Book a Demo

Author Topic: Any idea to do this directly?  (Read 4503 times)

iwt2

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Any idea to do this directly?
« 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.

peuhhhh

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Any idea to do this directly?
« Reply #1 on: August 04, 2010, 12:07:53 am »
hello iwt2,
did u try :
Code: [Select]
Repository.GetPackageByID(YourElement.PackageID) ;
?


iwt2

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Any idea to do this directly?
« Reply #2 on: August 04, 2010, 12:27:33 am »
Quote
hello iwt2,
did u try :
Code: [Select]
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?
« Last Edit: August 04, 2010, 12:28:41 am by iwt2 »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Any idea to do this directly?
« Reply #3 on: August 04, 2010, 12:58:24 am »
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
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Any idea to do this directly?
« Reply #4 on: August 04, 2010, 02:41:12 am »
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.
No, you can't have it!

iwt2

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Any idea to do this directly?
« Reply #5 on: August 04, 2010, 04:17:00 am »
great! just what I needed  :D.

thank you very much everybody.