1 Reply Latest reply: Jul 9, 2012 10:17 AM by MOMIR ZECEVIC RSS

    Automation plugin: how to select a spot channel when 2 channels have the same name?

    Royt2011 Community Member

      I have a CMYK document opened in photoshop. In "CHANNELS" panel, I just added 2 spot colors with the same name "Sport Color 1".

       

      As I click any of the spot channel to select it, the "Listener" plugin will output some c++ code like below:

       


      SPErr PlayeventSelect(/*your parameters go here*/void)
      {
           PIActionDescriptor result = NULL;
           DescriptorTypeID runtimeKeyID;
           DescriptorTypeID runtimeTypeID;
           DescriptorTypeID runtimeObjID;
           DescriptorTypeID runtimeEnumID;
           DescriptorTypeID runtimeClassID;
           DescriptorTypeID runtimePropID;
           DescriptorTypeID runtimeUnitID;
           SPErr error = kSPNoError;
           // Move this to the top of the routine!
           PIActionDescriptor desc0000000000003980 = NULL;

           error = sPSActionDescriptor->Make(&desc0000000000003980);
           if (error) goto returnError;

                // Move this to the top of the routine!
                PIActionReference ref0000000000001A48 = NULL;
                error = sPSActionReference->Make(&ref0000000000001A48);
                if (error) goto returnError;

                error = sPSActionReference->PutName(ref0000000000001A48, classChannel, "Spot Color 1");
                if (error) goto returnError;

           error = sPSActionDescriptor->PutReference(desc0000000000003980, keyNull, ref0000000000001A48);
           if (error) goto returnError;

           error = sPSActionControl->Play(&result, eventSelect, desc0000000000003980, plugInDialogSilent);
           if (error) goto returnError;

      returnError:
           if (result != NULL) sPSActionDescriptor->Free(result);
           if (desc0000000000003980 != NULL) sPSActionDescriptor->Free(desc0000000000003980);
           if (ref0000000000001A48 != NULL) sPSActionReference->Free(ref0000000000001A48);
           return error;
      }

       

      -------------------------------------------

      You can see "PutName" add the channel name "Spot Color 1" to reference, and I think it will not work correctly if I add such code to my project since PS cannot differentiate the 2 channels only by name. Can anyone tell me if there's any other method for selecting spot channel? Thanks in advance.