3 Replies Latest reply on Aug 4, 2017 1:33 AM by SuperMerlin

    Trying to reference a custom ActionDescriptor

    i73 Level 1

      I'm trying to create a global action descriptor that I can read from my C++ plugin in my photoshop application:

       

          //.net creation of the actionDesc

          app.DoJavascript("var desc = new ActionDescriptor(); desc.putString( 0 , app.activeDocument.name); app.putCustomOptions('Glob', desc, true);");

       

       

      I'm trying to get this descriptor in my plugin and I don't know if it's possible, is it possible to get a action descriptor by name in js, or is there a way in js I can return that 'desc' action descriptor?

        • 1. Re: Trying to reference a custom ActionDescriptor
          SuperMerlin Level 5
          dynamic app = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.Application"));
          

          To set :-

           

          dynamic desc = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.ActionDescriptor"))
                      desc.PutString(0, "Fred");
                      app.PutCustomOptions("UniqueName", desc, false); //Note false = this session only True will retain over all sessions.
          
          

           

          To get :-

          dynamic desc2 = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.ActionDescriptor"));
                      desc2 = app.GetCustomOptions("UniqueName");
                      MessageBox.Show((desc2.GetString(0)));
          
          

           

          Hope this helps.

          • 2. Re: Trying to reference a custom ActionDescriptor
            i73 Level 1

            A follow up Merlin, is it possible to get the current count of the string keys in the descriptor?

             

            I need to know what documents contain a file that was exported from an external app, so I would like to have multiple keys in the ActionDescriptor. Something like:

             

            desc.PutString(0, "imageA");

            desc.PutString(1, "imageB");

             

            //Changed to~

             

            desc.PutString(GetDescriptorKey(), "imageA") // count0

            desc.PutString(GetDescriptorKey(), "imageB") // count1

            • 3. Re: Trying to reference a custom ActionDescriptor
              SuperMerlin Level 5

              Yes...

              int count = desc.Count;