2 Replies Latest reply on Sep 11, 2016 1:31 AM by DBarranca

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

    DBarranca Level 4

      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

        • 1. Re: ActionDescriptor getter: can't use Property for nested Descriptors?
          Mikaeru69 Level 3

          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

          • 2. Re: ActionDescriptor getter: can't use Property for nested Descriptors?
            DBarranca Level 4

            Thanks so much Michel!

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

            Re: Brush Panel Transfer  Mode Toggle

             

            All the best!

             

            Davide