5 Replies Latest reply on Jun 8, 2012 5:27 AM by Russ Ward

    Passing an FDK object to ES

    Russ Ward Level 4

      Hi,

       

      As an FDK developer, I'm finding more and more reasons for interaction between API clients and ES scripts. For the most part, everything works very well, but I've run across an issue with CallClient() that I'm not able to figure out.

       

      In summary, I want to somehow return a document object from a client to ES. It is simple to return an FDK object handle (F_ObjHandleT) to other FDK clients (and to ES), but I can't see any way to convert an FDK object handle to an ES document object. For example, in my F_ApiNotify() FDK code, I can put something like this:

       

      F_ObjHandleT docId;

      docId = F_ApiGetId(0, FV_SessionId, FP_ActiveDoc);

      return (IntT)docId;

       

      ...and CallClient will get back the document ID. This is simple to work with if I made the call from another FDK client, but I don't know what to do with the ID within ES.

       

      For objects within documents, you can get around this by returning a unique ID (FP_Unique) of the object instead, which ES can readily convert back to an object with GetUniqueObject(). However, there is apparently no such property or method at the document level.

       

      Interestingly, it seems that you can go the other direction; that is, from an ES object to an object handle, using the 'id' property, as in:

       

      var oDoc = app.ActiveDoc;

      alert(oDoc.id);

       

      I don't know how reliable this is, though, as it seems to be undocumented. Anyway, what I want to do is go in reverse, so that a client can return something that uniquely identifies an open document.

       

      Any ideas?

       

      Thanks in advance,

      Russ

        • 1. Re: Passing an FDK object to ES
          FrameGurus

          Hi Russ,

           

          I understand that there is no straight way to do this. But the good news is- it is possible.

           

          From your FDK client it is possible to get the docid and pass it on to the extendscript. Now with this docid in hand you could traverse all open documents in your FrameMaker session and match the open documents in the session for this docid. An that's all. You have the document object to manipulate in the extendscript interface.

           

          Regards,

           

          framegurus

          email: framegurus@gmail.com

          • 2. Re: Passing an FDK object to ES
            Russ Ward Level 4

            Gurus,

             

            Thanks for the reply. I see where you are going with this... I'm assuming you are talking about traversing document IDs using the 'id' property of a document object, as in:

             

            oDoc.id

             

            That certainly would work, if the 'id' property is reliable as an F_ObjHandleT integer equivalent. Do you know that it is? I didn't see it in the documentation and the auto-complete feature doesn't seem to present it as an option. In my brief experiments, though, it seemed to work.

             

            Thanks,

            Russ

            • 3. Re: Passing an FDK object to ES
              4everJang Level 3

              Hi Russ,

               

              In the Extendscript Toolkit's databrowser I can see many items that have an undocumented 'id' property. I am not sure why it is undocumented but it looks like this is the handle that is being used for many settings that are defined in linked lists, such as Color, CondFmt, ElementDef, etc etc. There does not seem to be another way to get the right color etc except by traversing the linked list and matching its 'id' to the integer that is used in the setting. I have used this several times in my scripting and so far it has always worked.

               

              Ciao

               

              Jang

              • 4. Re: Passing an FDK object to ES
                saurabhatadobe Adobe Employee

                Hi Russ,

                 

                In response to your question: "That certainly would work, if the 'id' property is reliable as an F_ObjHandleT integer equivalent. Do you know that it is?"

                Yes, it is reliable and is the F_ObjHandleT integer equivalent.

                 

                Regards,

                Saurabh

                • 5. Re: Passing an FDK object to ES
                  Russ Ward Level 4

                  OK then, I believe this question is answered. While the solution takes a few lines of code, it is not overly burdensome. Thanks to all who took the time.

                   

                  Russ