Skip navigation
Currently Being Moderated

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

Jul 9, 2012 1:30 AM

Tags: #channel #sport #eventselect

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.

 
Replies
  • Currently Being Moderated
    Jul 9, 2012 10:17 AM   in reply to Royt2011

    Hi

     

    Here is the something from docs tht you may find usefull.

    Tryusing index instead of name:

     

    SPAPI OSErr(* PutIndex )(PIActionReference ref, DescriptorClassIDdesiredClass, uint32 value)
    Puts an index into a reference (formIndex) along with the desired class for the reference.

     

    Unfortunately I dont have C++ here to try i just used definition from docs.

    Hope that this help.

     

    Regards,

    Momir Zecevic

    Ars Media

    www.arsmedia.tv

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points