Skip to main content
Known Participant
January 11, 2019
Answered

Batch Action Stopped unintended when transform selection has no change

  • January 11, 2019
  • 5 replies
  • 1394 views

Hi,

i tried to make an action :

1...

2...

3. Transform selection with "Dialog", Where i can make selection myself.

4...

5...

Everything seem working fine when i make some change on transform selection. But when there is NO change, the script stopped unintended.

How can i solve this ?

This topic has been closed for replies.
Correct answer JJMack

It actually may not be a  bug if the transform selection is not changed enter cancels the transforn Selection.

The way I have always coded around this is to always  have the transform make a change. What? I simply record the interactive transform selection rotated 180 degrees.  The rotated selection is identical the the non rotated selection.  If the user hits enter to commit the transform the identical 180 degree selection is committed and the action continues the transform is not canceled.  The user must hit ESC to cancel the transform to stop the action. The user can then hit Play to retry doing the 180rotated transform selection again.

5 replies

Known Participant
January 14, 2019

Thanks JJMack, your solution 180degree rotation solve my problem. I usually use rectange selection.

Thanks Kukury and r-bin.

JJMack
Community Expert
Community Expert
January 11, 2019

It was never a problem for me in a script I only needed a work around in Actions.

try{

    //doAction("Interactive Transform", "Actions for Scripts"); // Let the user have the final word

    InteractiveTransform()

   }

catch(e){alert("Image Transform Canceled");}

try{

  //doAction("Interactive Transform", "Actions for Scripts"); // Let user have last say

  InteractiveTransform()

}

catch(e){}

//==================== Interactive Transform ==============

function InteractiveTransform() {

  // Menu Edit>Free transform

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Mn  '), cTID('MnIt'), cTID('FrTr'));

    desc1.putReference(cTID('null'), ref1);

    executeAction(cTID('slct'), desc1, DialogModes.NO);

};

JJMack
JJMack
Community Expert
JJMackCommunity ExpertCorrect answer
Community Expert
January 11, 2019

It actually may not be a  bug if the transform selection is not changed enter cancels the transforn Selection.

The way I have always coded around this is to always  have the transform make a change. What? I simply record the interactive transform selection rotated 180 degrees.  The rotated selection is identical the the non rotated selection.  If the user hits enter to commit the transform the identical 180 degree selection is committed and the action continues the transform is not canceled.  The user must hit ESC to cancel the transform to stop the action. The user can then hit Play to retry doing the 180rotated transform selection again.

JJMack
Kukurykus
Legend
January 11, 2019

Nice workaround!

Legend
January 11, 2019

This is similar to the bug in many versions of CC (in 2018 there is exactly).

Instead of calling the menu, use the transform command with small parameters, for example, 100.01%

Kukurykus
Legend
January 11, 2019

Actually that can be done by sole actions which I don't use from long, but now I remember I had the same problem I solved by recording minimal transformation that did not affect anything when I applied trasnsformation without transofrmation. So yes, it needs only to choose during transformation in upper bar 1/10 higher percent for width and height.

Kukurykus
Legend
January 11, 2019

$.level = 0; try{/*code for transformation*/}catch(err){}

You may also do it without try...catch statement by adding to your transformation code the part that I guess is missing:

dsc = new ActionDescriptor()

dsc.putUnitDouble(stringIDToTypeID('width'), stringIDToTypeID('percentUnit'), 100.000001)

dsc.putUnitDouble(stringIDToTypeID('height'), stringIDToTypeID('percentUnit'), 100.000001)

Note that dsc is the same you use in last line of your code before DialogModes.ALL, so you must change it to proper one.

Known Participant
January 11, 2019

Hi Kukurykus,

I am new on this so my question is how i can edit those codes?

Actually, i record action and then use File => automate => batch => with action recorded.

Kukurykus
Legend
January 11, 2019

Save it as "Transform Selection.jsx" (with Notepad incl. double quotion marks) to 'Presets/Scripts' folder of your Photoshop.

sTT = stringIDToTypeID

ref = new ActionReference(), dsc1 = new ActionDescriptor(), dsc2 = new ActionDescriptor()

ref.putEnumerated(sTT('layer'), sTT('ordinal'), sTT('targetEnum')), dsc1.putReference(sTT('null'), ref)

dsc1.putEnumerated(sTT('freeTransformCenterState'), sTT('quadCenterState'), sTT('QCSAverage'))

dsc2.putUnitDouble(sTT('horizontal'), sTT('pixelsUnit'), 0), dsc2.putUnitDouble(sTT('vertical'), sTT('pixelsUnit'), 0)

dsc1.putUnitDouble(sTT('width'), sTT('percentUnit'), t = 100.000001), dsc1.putUnitDouble(sTT('height'), sTT('percentUnit'), t)

dsc1.putEnumerated(sTT('interfaceIconFrameDimmed'), sTT('interpolationType'), sTT('bicubic'))

dsc1.putObject(sTT('offset'), sTT('offset'), dsc2), executeAction(sTT('transform'), dsc1, DialogModes.ALL)

Then relaunch Ps and instead of 'Transform Selection' step choose from dropdown Action panel menu 'Select Item' and then from 'File / Scripts' choose 'Transform Selection' item. Now this way 'Transform Selection' doesn't have to be made.