5 Replies Latest reply on Feb 16, 2012 7:39 PM by Wayne Matus

    How to get IEdmFile object in OnCmd routine (API question)

    Alexander Leisentritt

      Hi,

       

      I searched the API doc and the forums and the internet for almost two hours now and I don't find an answer.

       

      I am programming an AddIn for PDMWE and I want to read the values of a specific file.

      I don't find any routine in the API where I can generate a IEdmFile7 object by an ID or without the full path of the file.

       

      All examples in the doc need a file object in the call but how can I get that object from the things I know in the OnCmd routine aka the contents of the ppoData array?

       

      Any help appriciated.

       

      Regards

       

      Alexander


        • Re: How to get IEdmFile object in OnCmd routine (API question)
          Alexander Leisentritt

          Ok my fault... well I searched long but i think i found it...

           

          Its the "IEdmVault5::GetObject" function... sorry for bothering...

            • Re: How to get IEdmFile object in OnCmd routine (API question)
              Jeff Sweeney

              I'm with you Alexander, it is frustrating -almost all of the example assume you already have the file object.

               

              I think the reason why they are so vague is that methods for getting the file object differ depending on how the OnCmd routine was called. i.e. the parameters [ppoData] sent the OnCmd are different if the routine was called from a RMB click, from a button in a datacard or even different trigger types. Check the help file to see how the parameters are sent.

               

              Here is a simple example of how I get the file object if called via RMB click:

               

              First you need the vault object:

              objVault = poCmd.mpoVault
              

               

              Then once you have that, you can get the file object from the ID:

              objFile = objVault.GetObject(EdmObjectType.EdmObject_File, ppoData(X).mlObjectID1)
              

               

              Replace X with the number of file you are working with...if you have only one file selected, use 0. If you have more than one, typically you'ld cycle through with a For...Next loop.