Skip navigation
Currently Being Moderated

What's Wrong With This Code?

Apr 16, 2013 10:00 AM

I've been trying to get a test automaton plugin to work.  It builds correctly with no errors or warnings yet when I attempt to use it, I get no results.  No errors either.  All its intended to do is Copy > Make New Layer > Paste.  The code is below.  The sample code used was the MakeSelectFill plugin that I modified from the old 6.0 SDK along with using an older copy of Visual C++ that can open the project.  Any help is much appreciated.

 

//-------------------------------------------------------------------- -----------

#include <stdio.h>//defines sprintf

#include "PIUGet.h"//defines PIUGetInfo, not used in MakeSelectFill

#include "PIDefines.h"//defines __PIMac__, __PIWin__

#include "PIGeneral.h"//defines kPSPhotoshopCaller, kPSDoIt

#include "SPInterf.h"//defines kSPInterfaceCaller, kSPInterfaceAboutSelector,

                                                                                                               //kSPInterfaceStartupSelector,

#include "SPBasic.h"//defines SPBasicSuite

#include "SPAccess.h"//defines kSPAccessCaller, kSPAccessReloadSelector,

                                                                                                               //kSPAccessUnloadSelector, not used in MakeSelectFill

#include "PIActions.h"//defines PSActionDescriptorProcs, PSActionReferenceProcs,

                                                                                                               //PSActionControlProcs

#include "ADMBasic.h"//contains cross-platform alert dialogs, about boxes,

                                                                                                               //file and directory dialogs, string conversions

#include "PIUSuites.h"//defines PIUSuitesAcquire and PIUSuitesRelease

 

//-------------------------------------------------------------------- -----------

//          Function Prototypes.

//-------------------------------------------------------------------- -----------

 

DLLExport SPAPI SPErr PluginMain(const char* caller,

                                                                                 const char* selector,

                                                                                 const void* data );

 

//-------------------------------------------------------------------- -----------

//          Globals -- Define global variables for plug-in scope.

//-------------------------------------------------------------------- -----------

 

 

SPBasicSuite                              *sSPBasic = NULL;// the Basic Suite

 

 

//create pointers to the suites

PSActionDescriptorProcs          *sPSActionDescriptor = NULL;

PSActionReferenceProcs          *sPSActionReference = NULL;

PSActionControlProcs          *sPSActionControl = NULL;

PSActionListProcs                    *sPSActionList = NULL;

ADMBasicSuite                              *sADMBasic = NULL;

 

 

_AcquireList MySuites[] =

{

          kPSActionDescriptorSuite, kPSActionDescriptorSuiteVersion, (void **)&sPSActionDescriptor,

          kPSActionReferenceSuite, kPSActionReferenceSuiteVersion, (void **)&sPSActionReference,

          //note that the previous version of the Control suite is used for compatibility with 5.5

          kPSActionControlSuite, kPSActionControlSuitePrevVersion, (void **)&sPSActionControl,

          kPSActionListSuite, kPSActionListSuiteVersion, (void **)&sPSActionList,

          kADMBasicSuite, kADMBasicSuiteVersion, (void **)&sADMBasic

};

 

 

//-------------------------------------------------------------------- -----------

//

//          PluginMain

//

//          All calls to the plug-in module come through this routine.

//          It must be placed first in the resource. To achieve this,

//          most development systems require this be the first routine

//          in the source.

//

//          The entrypoint will be "pascal void" for Macintosh,

//          "void" for Windows.

//

//-------------------------------------------------------------------- -----------

 

 

DLLExport SPAPI SPErr PluginMain(const char* caller, // who is calling

                                                                                 const char* selector, // what they want

                                                                                 const void* data )// the message

{

          SPErr error = kSPNoError;

          SPMessageData *basicMessage = NULL;

 

          // all messages contain a SPMessageData*

          basicMessage = (SPMessageData *) data;

          sSPBasic = basicMessage->basic;

 

 

          // acquire all the global suite pointers now

          error = PIUSuitesAcquire(sSPBasic,

                                   MySuites,

                                   sizeof (MySuites) / sizeof (_AcquireList));

          if (error) return error;

 

          // check for SP interface callers

          if (sSPBasic->IsEqual((char*)caller, kSPInterfaceCaller))

          {

                    if (sSPBasic->IsEqual((char*)selector, kSPInterfaceAboutSelector))

                    {

 

 

                    }

          }

 

 

          // Photoshop is calling

          if (sSPBasic->IsEqual((char*)caller, kPSPhotoshopCaller))

          {

                    // the one and only message

                    if (sSPBasic->IsEqual((char*)selector, kPSDoIt))

                    {

 

                    }

          }

 

 

          // clean up, free memory

          PIUSuitesRelease(sSPBasic,

                           MySuites,

                           sizeof (MySuites) / sizeof (_AcquireList));

          return error;

 

 

}/*end PluginMain*/

 

 

//-------------------------------------------------------------------- -----------

//

//          Test Plugin

//

//          This plugin is used as a test.

//          Its functions are Copy > Make New Layer > Paste

//

//

//-------------------------------------------------------------------- -----------

SPErr Copy(void)

{

     PIActionDescriptor result = NULL;

     SPErr error = kSPNoError;

     error = sPSActionControl->Play(&result, eventCopy, NULL, plugInDialogSilent);

     if (error) goto returnError;

 

 

returnError:

     if (result != NULL) sPSActionDescriptor->Free(result);

     return error;

}

 

 

//make new layer here//

 

 

SPErr MakeLayer(void)

{

          PIActionDescriptor descriptor = NULL;

          PIActionReference reference = NULL;

          PIActionDescriptor result = NULL;

          SPErr error = kSPNoError;

 

 

          error = sPSActionDescriptor->Make(&descriptor);

          if (error) goto returnError;

                    // Move this to the top of the routine!

                    error = sPSActionReference->Make(&reference);

                    if (error) goto returnError;

                    error = sPSActionReference->PutClass(reference,classLayer);

                    if (error) goto returnError;

                    error = sPSActionDescriptor->PutReference(descriptor,keyNull,reference);

                    if (error) goto returnError;

                    error = sPSActionControl->Play(&result,eventMake,descriptor,plugInDialogSilen t);

                    if (error) goto returnError;

returnError:

                    if (result != NULL) sPSActionDescriptor->Free(result);

                    if (descriptor != NULL) sPSActionDescriptor->Free(descriptor);

                    if (reference != NULL) sPSActionReference->Free(reference);

                    return error;

}

 

 

//end make new layer//

 

 

//start paste//

 

 

SPErr Paste(void)

{

PIActionDescriptor result = NULL;

SPErr error = kSPNoError;

error = sPSActionControl->Play(&result,eventPaste,NULL,plugInDialogSilent);

if (error) goto returnError;

returnError:

if (result != NULL) sPSActionDescriptor->Free(result);

return error;

}

 

 

//end paste//

 

 

 

 

// all windows plug-ins need a DllMain

 

 

#ifdef __PIWin__

BOOL APIENTRY DllMain( HANDLE hModule,

                                                          DWORD ul_rearson_for_call,

                                                          LPVOID lpReserved )

{

          return TRUE;

}

#endif

 
Replies
  • Currently Being Moderated
    May 16, 2013 10:10 PM   in reply to SuperBeer Dude

    You seem to be missing something inside here. Probably Copy();MakeLayer();Paste();

     

    // Photoshop is calling

              if (sSPBasic->IsEqual((char*)caller, kPSPhotoshopCaller))

              {

                        // the one and only message

                        if (sSPBasic->IsEqual((char*)selector, kPSDoIt))

                        {

     

                        }

              }

     
    |
    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