7 Replies Latest reply: Jan 8, 2014 12:00 AM by _MBK_ RSS

    Plugin loses some actions in progress

    _MBK_ Community Member

      Please, help me!

      I perform certain actions within its handler menu goМenuItem - delete some objects; do other invisible; run through certain actions by PlayActionEvent(), e.t.c. then export the file again through PlayActionEvent("adobe_exportDocument" ...) and see that after all my activities were canceled - a document recovered to the initial state, and after each export and save the need to repeat the entire sequence again. Moreover, on some computers to export certain actions randomly do not work. What am I doing wrong? Sorry for my bad English

        • 1. Re: Plugin loses some actions in progress
          _MBK_ Community Member

          Try to give an example. I wrote the following code:

          ...

          void DoSaveAsEPS(char * path)

          {

                    AIErr result;

                    AIActionParamValueRef  valueParameterBlock2 = NULL, 

                    ActionDialogStatus dialogStatus1 = kDialogOff, dialogStatus2 = kDialogOff;

            result = sAIActionManager->AINewActionParamValue(&valueParameterBlock1);

            result = sAIActionManager->AINewActionParamValue(&valueParameterBlock2);

                              if (valueParameterBlock2) {

             result = sAIActionManager->AIActionSetString(valueParameterBlock2, 'name', path);

              result = sAIActionManager->AIActionSetString(valueParameterBlock2, 'frmt', "Adobe Illustrator EPSF");

              result = sAIActionManager->AIActionSetInteger(valueParameterBlock2, 'wfmt', 5);

          result = sAIActionManager->AIActionSetInteger(valueParameterBlock2, 'crtr', 10);

                                        result = sAIActionManager->AIActionSetInteger(valueParameterBlock2, 'ext.', 0);

                                        result = sAIActionManager->AIActionSetBoolean(valueParameterBlock2, 'iplc', false);

                                        result = sAIActionManager->AIActionSetBoolean(valueParameterBlock2, 'ithm', true);

            result = sAIActionManager->AIActionSetInteger(valueParameterBlock2, 'ifmt', 1);

                                        result = sAIActionManager->AIActionSetBoolean(valueParameterBlock2, 'icjk', true);

                                        result = sAIActionManager->AIActionSetInteger(valueParameterBlock2, 'pslv', 2);

                                  }

            result = sAIActionManager->PlayActionEvent( "adobe_saveDocumentAs", dialogStatus2, valueParameterBlock2 );

          }

          ...

           

          extern AIErr goMenuItem( AIMenuMessage *message ) {

          ...

          spec.type = kTextFrameArt;

          spec.whichAttr = 0;

          spec.attr = 0;

          (void) sAIMatchingArt->GetMatchingArt( &spec, 1, &artStore, &numMatches );

           

          // Here the value of numMatches is, for example 3

           

          for( i = 0; i < numMatches; i++ )

                  {

           

                    artHandle = (*artStore)[i];

           

                    error = sAIArt->DisposeArt( artHandle);  

                  }

          (void) sAIMatchingArt->GetMatchingArt( &spec, 1, &artStore, &numMatches );

           

          // Here the value of numMatches is zero, because text objects are removed

           

          DoSaveAsEPS("c:\1.eps");

           

          (void) sAIMatchingArt->GetMatchingArt( &spec, 1, &artStore, &numMatches );

          // Here the value of numMatches is 3 again, text objects spontaneously recovered.

          ...

           

          How can this be?

          • 2. Re: Plugin loses some actions in progress
            A. Patterson Community Member

            When you run the action, you're obviously executing the same code that Adobe does when they do it through the UI. One thing I've noticed is that a few of the 'Save As' operations seem to run undo as one of their last steps. Presumably because while they're doing their export work they do some things to the artboard and have to put it back the way they found it. There isn't an easy way to avoid this unfortunately; mainly you just have to notice it and work around it.

            • 3. Re: Plugin loses some actions in progress
              _MBK_ Community Member

              On closer inspection it turned out that this effect is observed not only with PlayActionEvent, but just when you save through WriteDocument. So I do not know how to get around this bug? Sometimes it helps to use SetDocumentModify(true), but, unfortunately, it works very unstable. How can this be done correctly?

              • 4. Re: Plugin loses some actions in progress
                A. Patterson Community Member

                Yes, I should have said we've noticed it outside of actions too. Basically, you just have to work around it the hard way. In the example code you described, I'd just re-delete my artwork afterwards. It's very annoying, but there's no way around it that we've found.

                • 5. Re: Plugin loses some actions in progress
                  _MBK_ Community Member

                  That is, do you offer after every save and export the new repeat the entire sequence with the document? I tried so, but on some versions of illustrator it does not work - after a sequence of saving document, some action begins randomly ignored. :-(

                  Therefore, I would like to know - how to do it right? After using scripting and recorded actions, are not lost after every save, that is itself Adobe as it does?

                  • 6. Re: Plugin loses some actions in progress
                    _MBK_ Community Member

                    It turns out that this bug is present in scripting too.

                    Execute the following java code:

                     

                    ...

                    for (j=0;j<it.length;j++ )

                    {

                    if (it.typename=="rasterItem")

                    {

                    it.remove();

                    }

                    }

                    activeDocument.saveAs(fileSpec,EPSexportOptions);

                    ...

                     

                    Gets two document windows - in one raster objects are removed, and in the other - remained unchanged.

                    • 7. Re: Plugin loses some actions in progress
                      _MBK_ Community Member

                      Sorry, I was wrong.

                      Scripting working properly