Copy link to clipboard
Copied
We converted an ATN to JSX and in the ATN the STOP command was used. STOP was converted properly but what is needed in JSX is that stop needs to wait for user to complete the task at that time. The action leaves things running as is so user can finish and the Click PLAY to resume. The user is using the select tool when the stop is done.
Any to do in JSX?
RONC
The basic problem is Action stop brake the action into parts. Each part is player by the user clicking the play button to play the next part of the action and the same document need to be the active document in the right state.
The easiest way to convert this type of action to a script is use X's action file to script then brake the script produced into the Action Parts. If there are two stops in an action there would be three scripts. ActionPart1 ActionPart2 ActionPart3. Instead of clicking
...Copy link to clipboard
Copied
Post your code (at least that working part with a problem) so I'll make modification. It's hard to talk about thing I don't see.
Copy link to clipboard
Copied
if you want to intervene with a block
you have to put the block
example
step8 (true, true)
Copy link to clipboard
Copied
I completetly don't understand your answer to him
Copy link to clipboard
Copied
Kukurykus
I think I understand that he would like to stop the script
with a stop like in the example below
//#target photoshop
//
// test.jsx
//
//
// Generated Sun Jan 28 2018 18:15:39 GMT+0100
//
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
//
//==================== test ==============
//
function test() {
// Crea
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(cTID('Lyr '));
desc1.putReference(cTID('null'), ref1);
executeAction(sTID('make'), desc1, dialogMode);
};
// Unisci visibili
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putBoolean(cTID('Dplc'), true);
executeAction(sTID('mergeVisible'), desc1, dialogMode);
};
// Imposta
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putString(cTID('Nm '), "layer test");
desc1.putObject(cTID('T '), cTID('Lyr '), desc2);
executeAction(sTID('set'), desc1, dialogMode);
};
// Crea
function step4(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(sTID("contentLayer"));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
var desc4 = new ActionDescriptor();
desc4.putDouble(cTID('Rd '), 174.000004827976);
desc4.putDouble(cTID('Grn '), 70.2840457856655);
desc4.putDouble(cTID('Bl '), 70.2840457856655);
desc3.putObject(cTID('Clr '), sTID("RGBColor"), desc4);
desc2.putObject(cTID('Type'), sTID("solidColorLayer"), desc3);
desc1.putObject(cTID('Usng'), sTID("contentLayer"), desc2);
executeAction(sTID('make'), desc1, dialogMode);
};
// Imposta
function step5(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(cTID('Md '), cTID('BlnM'), cTID('SftL'));
desc1.putObject(cTID('T '), cTID('Lyr '), desc2);
executeAction(sTID('set'), desc1, dialogMode);
};
step1(); //
step2(); //
step3(); //
step4(true, true);
step5(); //
};
//=========================================
// test.main
//=========================================
//
test.main = function () {
test();
};
test.main();
// EOF
"test.jsx"
// EOF
Copy link to clipboard
Copied
Ok, I feel stupid now you probably refer to some xbytor2 script I didn't know and he possibly used but didn't mention...
Copy link to clipboard
Copied
Have to blame everything on me not xbytor. Sorry
RONC
Copy link to clipboard
Copied
rechmbrs
I do not understand English very well
if you can explain yourself better on what you want to do
we can help you better
Copy link to clipboard
Copied
Thanks for the response.
The script builds a diagnostic as it goes from step to step. At a point in the script a decision has to be made. The diagnostic is displayed for the script user to evaluate. The user should be able to say that the diagnostic is good and that the script should continue on or the user should state that the diagnostic needs more work and the script should allow the user to use the eraser tool to fix the problem and then tell the script to use the corrected image to continue with the same steps as the good image was sent to.
Please ignore our script and just consider what I have stated.
RONC
Copy link to clipboard
Copied
That's easy but not with script you use. Consider following construction then:
#target photoshop
if (!$.getenv('continue') {
alert('First steps of script'), $.setenv('continue', 1)
// time to use eraser and continue script hitting button
// or continue script with no prior action by hitting buutton
}
else {
alert('Next steps of script'), $.setenv('continue', '')
}
if statement sets global variable to true. So next time (after script stopped and you used eraser or not) it checks that global variable is set to true. For the script it's command to execute else statement. So you pressed bound button and your script continued with else statement. After all steps of else statement are finished, script sets global variable back to false, so next time you run script it starts working again from if statement. That above sample is working, try it to understand me better...
Copy link to clipboard
Copied
the script could be useful
I did not understand how to make it work
you could post an example.
Copy link to clipboard
Copied
This is already very clear example
You put all his steps from first one he uses in script to 74, and then 75 (which I guess choose Eraser Tool). While step 77, and all others there are you put to else statement. When you run script it goes thru all steps to step 75, then it stops. When you rerun script it continues working from step 77. And so on, when you run script once again it starts from step 1 to stop at step 75, to go further from step 77 when you use (or not) Eareser Tool and run script again. But will his script accept this change?
Here's an example done on @geppettol66959005 script who asked me privately to demonstrate how that could be used in his script. Second part is his original script you have to replace 8 steps part (at bottom of script) to this little modification:
if (!$.getenv('continue')) {
step1(); // Crea
step2(); // Unisci visibili
step3(); // Crea
step4(); // Selezione
step5(); // Crea
step6(); // Imposta
step7(); // Selezione
$.setenv('continue', 1)
}
else {
step8(); // Unisci visibili
$.setenv('continue', '')
}
// script
// TEST
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
//
//==================== Azione 1 ==============
//
function Azione1() {
// Crea
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(cTID('Lyr '));
desc1.putReference(cTID('null'), ref1);
executeAction(sTID('make'), desc1, dialogMode);
};
// Unisci visibili
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putBoolean(cTID('Dplc'), true);
executeAction(sTID('mergeVisible'), desc1, dialogMode);
};
// Crea
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(cTID('AdjL'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putClass(cTID('Type'), sTID("vibrance"));
desc1.putObject(cTID('Usng'), cTID('AdjL'), desc2);
executeAction(sTID('make'), desc1, dialogMode);
};
// Selezione
function step4(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Chnl'), cTID('Chnl'), sTID("RGB"));
desc1.putReference(cTID('null'), ref1);
desc1.putBoolean(cTID('MkVs'), false);
executeAction(sTID('select'), desc1, dialogMode);
};
// Crea
function step5(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(cTID('AdjL'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
desc3.putEnumerated(sTID("presetKind"), sTID("presetKindType"), sTID("presetKindDefault"));
desc2.putObject(cTID('Type'), cTID('Crvs'), desc3);
desc1.putObject(cTID('Usng'), cTID('AdjL'), desc2);
executeAction(sTID('make'), desc1, dialogMode);
};
// Imposta
function step6(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('AdjL'), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(sTID("presetKind"), sTID("presetKindType"), sTID("presetKindCustom"));
var list1 = new ActionList();
var desc3 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnumerated(cTID('Chnl'), cTID('Chnl'), cTID('Cmps'));
desc3.putReference(cTID('Chnl'), ref2);
var list2 = new ActionList();
var desc4 = new ActionDescriptor();
desc4.putDouble(cTID('Hrzn'), 0);
desc4.putDouble(cTID('Vrtc'), 0);
list2.putObject(cTID('Pnt '), desc4);
var desc5 = new ActionDescriptor();
desc5.putDouble(cTID('Hrzn'), 73);
desc5.putDouble(cTID('Vrtc'), 50);
list2.putObject(cTID('Pnt '), desc5);
var desc6 = new ActionDescriptor();
desc6.putDouble(cTID('Hrzn'), 191);
desc6.putDouble(cTID('Vrtc'), 218);
list2.putObject(cTID('Pnt '), desc6);
var desc7 = new ActionDescriptor();
desc7.putDouble(cTID('Hrzn'), 255);
desc7.putDouble(cTID('Vrtc'), 255);
list2.putObject(cTID('Pnt '), desc7);
desc3.putList(cTID('Crv '), list2);
list1.putObject(cTID('CrvA'), desc3);
desc2.putList(cTID('Adjs'), list1);
desc1.putObject(cTID('T '), cTID('Crvs'), desc2);
executeAction(sTID('set'), desc1, dialogMode);
};
// Selezione
function step7(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Chnl'), cTID('Chnl'), sTID("RGB"));
desc1.putReference(cTID('null'), ref1);
desc1.putBoolean(cTID('MkVs'), false);
executeAction(sTID('select'), desc1, dialogMode);
};
// Unisci visibili
function step8(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putBoolean(cTID('Dplc'), true);
executeAction(sTID('mergeVisible'), desc1, dialogMode);
};
step1(); // Crea
step2(); // Unisci visibili
step3(); // Crea
step4(); // Selezione
step5(); // Crea
step6(); // Imposta
step7(); // Selezione
step8(); // Unisci visibili
};
//=========================================
// Azione1.main
//=========================================
//
Azione1.main = function () {
Azione1();
};
Azione1.main();
Copy link to clipboard
Copied
I'm afraid we get a run time error 24 stating that either Step1(); or Step77(); is not a function.
I've marked our changes by comments.
HELP please,
RONC
//*************************************************************//
if (!$.getenv('continue')) // added extra )
{
alert('First steps of script'); //changed , to ;
$.setenv('continue', 1)
// time to use eraser and continue script hitting button
// or continue script with no prior action by hitting button
step1(true, true); // Stop
step2(); // Flatten Image
step3(); // Image Size
////////// step4-step70 removed from this not original
step71(); // Set
step72(); // Delete
step73(); // Delete
step74(); // Set Eraser
step75(true, true); // Select
}
else
{
alert('Next steps of script'); //changed , to ;
$.setenv('continue', '')
/* step76(true, true); // Stop */ //remover from original per instructions
step77(); // Set
step78(); // Hide
////////// step79-step90 removed from this not original
step91(); // Merge Layers
step92(true, true); // Stop
};
Copy link to clipboard
Copied
excuse my reflection
but you can not use it
step8 (false, false);
to skip the function
Copy link to clipboard
Copied
That what you did can't work, because you removed your functions (it's why you're getting that error), and left only steps() parts which call the (not existing right now in your current code) functions. Get back them so maybe that will finally work...
Beside you didn't understand my answer to @geppettol66959005, who btw didn't understand too my last reply (what I'm seeing from his next private message). I didn't mean to replace whole code of him, but only a part to that code I posted:
step1(); // Crea
step2(); // Unisci visibili
step3(); // Crea
step4(); // Selezione
step5(); // Crea
step6(); // Imposta
step7(); // Selezione
A shortened and more readable code won't work too, because there are no functions of your original script, steps call them:
if (!$.getenv('continue')) {
step1(true, true); // Stop
step2(); // Flatten Image
step3(); // Image Size
step71(); // Set
step72(); // Delete
step73(); // Delete
step74(); // Set Eraser
step75(true, true); // Select
$.setenv('continue', 1)
}
else {
step77(); // Set
step78(); // Hide
step91(); // Merge Layers
step92(true, true); // Stop
$.setenv('continue', '')
}
Copy link to clipboard
Copied
I didn't remove the actual build of the steps. I didn't send that part hoping it doesn't matter.
Can't I do this by just save a variable to disk and not using getinv and setinv.
Is there really a problem having true, true or false, false in a function call?
RONC
Copy link to clipboard
Copied
That won't change anything you save variables to disk or they will be part of environment. Problem with true, false in function I just solved other way to stop script and continue it, and it's not something I thought up, but xbytor2 so you should ask for him or someone who uses such scripts. If you kept functions in your script but didn't post them here and getting error that function doesn't exist then investigate why that happen. I can not be any of help when I don't see code.
Copy link to clipboard
Copied
The basic problem is Action stop brake the action into parts. Each part is player by the user clicking the play button to play the next part of the action and the same document need to be the active document in the right state.
The easiest way to convert this type of action to a script is use X's action file to script then brake the script produced into the Action Parts. If there are two stops in an action there would be three scripts. ActionPart1 ActionPart2 ActionPart3. Instead of clicking the Play button to play the next part of the action you run the next script part.
Copy link to clipboard
Copied
Either 2 - 3 scripts, or just one with if, else if and/or else statement depending what is stored in 'env' at the time of running.
Copy link to clipboard
Copied
I find it better to store the data in the document metadata, rather the in a global environment variable or a custom script option . Keep it with the document being worked one. If you stop execution what to stop the user from using the script or an action the user the script on an other document and mess with the environment variable or custom script option.
You also need to know how to code. Not juste use X's actionfile to script to generate action manager code.
Copy link to clipboard
Copied
I use both methods to store variables (env and meta), but here a problem is not a method but his ability to use anything that could work whatever he'll decide to use for raliability in future. For now he's figuring out what to do with given tips
Copy link to clipboard
Copied
Thanks for the help. After taking in all of the good information from you, we have the script working. We broke it into portions and many of our problems went away. Also decided to make the Action work to match script which will be much easier to understand for the users.
I hit the jackpot with this group. JJ always has a few that helps so many.
My appreciation,
RONC
Copy link to clipboard
Copied
This is part of code and sorry I misstated at end of script.
If STOP were at the end it works but unless we STOP it before step 77, the user doesn't have time to finish and no way to signal when finished so that the script can continue.
Sorry for my mixup.
See my comments in between code segments.
RONC
function step74(enabled, withDialog)
{
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(PSClass.Channel, PSString.selection);
desc1.putReference(PSKey.Target, ref1);
desc1.putEnumerated(PSKey.To, PSType.Ordinal, PSEnum.None);
executeAction(PSEvent.Set, desc1, dialogMode);
};
// Select
function step75(enabled, withDialog)
{
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(PSClass.EraserTool);
desc1.putReference(PSKey.Target, ref1);
executeAction(PSEvent.Select, desc1, dialogMode);
};
//***************************************************************************************************
// We would like to complete this step or bypass it entirely with user saying so then continue to step 77.
// Stop usage came over from ATN so not same as what I said as they didn't try to bypass step 75
//***************************************************************************************************
// Stop
function step76(enabled, withDialog)
{
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putString(PSKey.Message,
"Stop for fixup.\r\rAfterwards, press Play to continue."
);
desc1.putBoolean(PSKey.Continue, true); // Inserted by RONC not correct???
executeAction(PSEvent.Stop, desc1, dialogMode);
};
// Set
function step77(enabled, withDialog)
{
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
desc1.putReference(PSKey.Target, ref1);
var desc2 = new ActionDescriptor();
var list1 = new ActionList();
list1.putEnumerated(PSClass.Channel, PSKey.Red);
desc2.putList(PSString.channelRestrictions, list1);
var desc3 = new ActionDescriptor();
desc3.putUnitDouble(PSKey.Scale, PSUnit.Percent, 100);
desc2.putObject(PSKey.LayerEffects, PSKey.LayerEffects, desc3);
desc1.putObject(PSKey.To, PSClass.Layer, desc2);
executeAction(PSEvent.Set, desc1, dialogMode);
};
step74(); // Set
step75(); // Select
step76(true, true); // Stop
step77(); // Set
Copy link to clipboard
Copied
There are two kinds of stops in Actions. Stop and Stops with continue. Both can stop the playing of the action and leave the Action position to start playing at the next step in the action after the stop step. You can do anytime you want in Photoshop and when done click play to continue the action. The difference between the two stops is the if you juste wanted to put our a message to the user Stop with conduce allows the user to just to acknowledge that they saw the mess by pressing enter and the action continues. That is like an alert in a script. There is no concept stop in scripting where a script can be started from a different step. You would need to program the script with some logic that would know what part of the script to run each time you run it. I use the document metadata instruction field to record that information. The first my scripts of this type does is look to see what it has recorded there. If it finds none of its recordings in there it know it the first time the script is being run on this document to do its stuff. So it runs part 1 which notes in the instruction field its information and ends execution which could be a message to the user to do something and run the script again. The next time the script is run on the document the script will rune the next part. If part is the last part all of the scripts information will be removed from the instruction field and the scrip will end execution. The allows the full process be done more the one time on a document.
My script all use the instruction field and do not interfere with each be preserving data in the field which is not theirs. My scripts for the most part do not put out message and the user does not know they are using the script more than one. Most of my scripts of the scripts of this type I have were written for use within Actions or toggle function for documents. They are more or less like save and restore steps for action One may save the resolution and ruler in use for the Document in the instruction field. Than action is free to scale the document to a known size without reapplying. The resize a watermark for this size document or select a font size for this size document add the text or watermark then run the script a second time to restore the document resolution scale it back to it original scale..
However Adobe added a bug into scripting in CC 2015.5 and will not allow you to set the instruction files back to null if it were null to begin with. So I set up script event manager new document and open document event to add garbage to the instruction field if it is not in there so the field will not be null.
Adobe add some strang bugs and makes statemnts like its bad to remove copyrights. I do not understand that for they let your set the copyright to anything yow want to using Photoshop's file info. I was jsut trying to set the instruction filed to what it was without the scripts information.
Jeffrey Tranberry, Sr. Product Manager, Digital Imaging