Skip to main content
Inspiring
August 2, 2017
Answered

Trying to reference a custom ActionDescriptor

  • August 2, 2017
  • 1 reply
  • 1201 views

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?

This topic has been closed for replies.
Correct answer SuperMerlin

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.

1 reply

SuperMerlin
SuperMerlinCorrect answer
Inspiring
August 2, 2017

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.

i73Author
Inspiring
August 3, 2017

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

SuperMerlin
Inspiring
August 4, 2017

Yes...

int count = desc.Count;