• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ActionDescriptor getter: can't use Property for nested Descriptors?

Advocate ,
Sep 10, 2016 Sep 10, 2016

Copy link to clipboard

Copied

When retrieving an ActionDescriptor, like the application's, we've been instructed to prepend the property we're interested into, so that we're not getting the entire app descriptor, but only the bit we really need:

// DON'T

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var applicationDesc = executeActionGet(ref);

var theInterpolationMethod = typeIDToStringID(applicationDesc.getEnumerationValue(stringIDToTypeID('interpolationMethod')));

alert (theInterpolationMethod);

// DO

var ref = new ActionReference ();

ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("interpolationMethod")); /* <-- ADD THIS */

ref.putEnumerated (stringIDToTypeID ("application"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));

var interpolationDesc = executeActionGet (ref);

var theInterpolationMethod = typeIDToStringID (interpolationDesc.getEnumerationValue (stringIDToTypeID ("interpolationMethod")));

alert (theInterpolationMethod);

So far so good.

Problem is that this putProperty works only when you're looking for a value such as Enumeration, Integer, String, Boolean. If you need to get a nested descriptor like "currentToolOptions", it doesn't work:

// FAILS

var ref = new ActionReference ();

ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("currentToolOptions"));

ref.putEnumerated (stringIDToTypeID ("application"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));

var desc = executeActionGet (ref).getObjectValue (stringIDToTypeID ("currentToolOptions")); // FAILS here

desc;

// WORKS

var ref = new ActionReference ();

// ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("currentToolOptions")); // Removed the prepended property

ref.putEnumerated (stringIDToTypeID ("application"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));

var desc = executeActionGet (ref).getObjectValue (stringIDToTypeID ("currentToolOptions"));

desc;

... and you have to get the entire app's descriptor (bad for performance) and then extract the bit you want.

Has anyone an idea why is it so, or in case how to correctly prepend the property for DescValueType.OBJECTTYPE?

Thank you!

Davide

TOPICS
Actions and scripting

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Sep 10, 2016 Sep 10, 2016

Hi Davide,

Getting a nested object property is usually not a problem. Unfortunately, there is a bug feature in getting the current tool options in CS4, and it seems it is still there in later versions.

- Getting directly the "currentToolOptions" property triggers the error: "The command Get is not currently available"!

- Getting the "tool" property returns *both* the "tool" and the "currentToolOptions" properties!

var ref = new ActionReference ();

ref.putProperty (stringIDToTypeID ("property"), strin

...

Votes

Translate

Translate
Adobe
Guest
Sep 10, 2016 Sep 10, 2016

Copy link to clipboard

Copied

Hi Davide,

Getting a nested object property is usually not a problem. Unfortunately, there is a bug feature in getting the current tool options in CS4, and it seems it is still there in later versions.

- Getting directly the "currentToolOptions" property triggers the error: "The command Get is not currently available"!

- Getting the "tool" property returns *both* the "tool" and the "currentToolOptions" properties!

var ref = new ActionReference ();

ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("tool"));

ref.putEnumerated (stringIDToTypeID ("application"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));

var desc = executeActionGet (ref);

alert (typeIDToStringID (desc.getEnumerationType (stringIDToTypeID ("tool"))));

alert (typeIDToStringID (desc.getObjectType (stringIDToTypeID ("currentToolOptions"))));

desc = desc.getObjectValue (stringIDToTypeID ("currentToolOptions"));

HTH,

--Michel

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 11, 2016 Sep 11, 2016

Copy link to clipboard

Copied

LATEST

Thanks so much Michel!

Do you think this same bug feature may be the key to open this door too?

Brush Panel Transfer Mode Toggle

 

All the best!

 

Davide

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines