Copy link to clipboard
Copied
I need script for very boring task if possible to automate at least something in this work which consist of several thousand repeats multiplied by 5 steps. In essence I am replacing Set Work Path step with new path. Here are steps I am taking to accomplish task:
// select next path;
// 2020, use it at your own risk;
if (app.documents.length > 0) {
var thisPathIndex = selectedPath ();
if (thisPathIndex != null) {
if (thisPathIndex == activeDocument.pathItems.length) {thisPathIndex = 1}
else {thisPathIndex++};
var desc28 = new ActionDescriptor();
var ref5 = new ActionReference();
ref5.putIndex( stringIDToTypeID( "path" ), thisPathIndex );
desc28.putReference( stringIDToTypeID( "null" ), ref5 );
executeAction( stringIDToType...
Copy link to clipboard
Copied
@Bojan Živković – I'd like to help, but I don't know where/how to start?
Copy link to clipboard
Copied
Please watch just posted video explanation.
Copy link to clipboard
Copied
One could include the »Insert Path«-paths into a Script, how many different Paths are there?
Do you use them just for creating Selections or something else, too?
Copy link to clipboard
Copied
I am replacing exactly 100 paths. Thats one action which serves as template. Everything is the same beside paths. I am replacing paths or recording new path outline using Insert Path and deleting old path outline or existing Set Work Path step.
Copy link to clipboard
Copied
Sorry, I do not understand.
What about the Work Path?
Which paths exist?
What do they get replaced with?
Copy link to clipboard
Copied
I just posted video explanation.
Copy link to clipboard
Copied
No showed action set and not explained which 'Set Work Path' items are previous / next to each other.
Copy link to clipboard
Copied
I have action which serves as template. There are 100 Set Work Path steps and 100 path outlines in the Paths panel. Each time I am selecting next or below Set Work Path step, also selecting below path outline in Paths panel then using Insert Path to record new Set Work Path step which will be recorded just below existing Set Work Path step. I must select and delete original Set Work Path step....
Copy link to clipboard
Copied
It'll be easier to help if you share the action with a file to try it on.
Copy link to clipboard
Copied
Of course I will, watch this video and if you still need action and file will upload https://www.screencast.com/t/9DikEWrmN2
Copy link to clipboard
Copied
Combining it with action makes it harder to do. The sole script would be sufficient.
Which repetable steps of your manual doings you would like to be written to script?
Copy link to clipboard
Copied
You mean it is difficult to select step in action and delete it? I would like, as mentioned in video, to have script that will:
At least 2 adjacent steps of above 4 must be included because there is shortcut for Insert Path menu item.
Copy link to clipboard
Copied
It's harder, so I mean what (not actions) steps you'd include as another commands of script.
Copy link to clipboard
Copied
None, that is enough, 4 steps above mentioned.
Ideally, 5th step will be to select next below instance of Set Work Path and repeat but that is probably too much and it needs to stop with loop at some point. There are actually 100 Set Work Path steps but that would be tooo much. I need only to insert paths nothing else shoould be changed, all other steps remains the same all the time and nothing else is needed.
Copy link to clipboard
Copied
I don't need to know what action steps are. Forget about them, just say what steps starting from 3rd are your manual doings to make from them a looped code.
Copy link to clipboard
Copied
After inserting path using Insert Path which will create new step Set Work Path. Now I have 2 steps Set Work Path one below another where bottom one is selected. My manual doing is:
Copy link to clipboard
Copied
You don't understand me 🙂 I don't want to do it involving the action, only the script and nothing else. So if you'll describe single sequence, I'm going to make the script from. Imagine you do it without action, all manually within one path item yet, step by step (with no action).
Copy link to clipboard
Copied
I do not understand you. I am recording action, action steps, without action and action steps involved script can't do much for me.
Copy link to clipboard
Copied
I wanted to avoid combining script with action, especially when you didn't share it to make it easier to recrate what you do. The script can do much more and easier than action so there is no need to use action together with script. Maybe someone else will explain what I mean...
Copy link to clipboard
Copied
I asked for script to help me record action step if that is possible. I do not want script instead of action.
I saw in scripting reference Next path so it is probably possible to select next or below path via script. Why not to use Insert Path menu item via script? I guess and that is possible. Not sure if script can select previous/next step in action but it should be able to delete step in action.
Above is presented only 1,4% of entire action and it has 100 Set Work Path steps. I am recording 100 by 100 steps. I will merge later all parts. I must record action, script instead of action is not an option.
Copy link to clipboard
Copied
Okay, so you want to do it by action, replace indicated items. That's possible to do by script how ever I don't play with actions anymore, so I would have to refresh my memory. Instead that I can propose you simple script that takes to memory all (100) paths and for each execute short 4 steps codes. That let you make one repetitive loop for all your paths. As to the Action & Script I'm sure 2 other participants of this thread help you soon 😉
Copy link to clipboard
Copied
It would need more complex scripting to loop through action steps and to connect 2 loops. Do not waste time, I do not think this will go that far. I would be satisfied with simple script which I will run over and over without complex loops.
Copy link to clipboard
Copied
@Bojan Živković wrote:
I saw in scripting reference Next path so it is probably possible to select next or below path via script.
Bojan, what is this JS method for selecting next path?
I am not aware of a (relative) way to select paths in JS, I am only aware of the ability to select path by (absolute) name or by (absolute) index number.
Is there a keyboard shortcut as there is with layers?
P.S. It is probably easy for those with AM code knowledge to get the active path item index number, then +1 increment this value to select the next path index number in order to create a "relative select next path function", however, that is beyond my knowledge.
Copy link to clipboard
Copied
I'm sure that this is more complex and verbose than it needs to be, however, I was happy to get this relative path selection function working:
Select Next Path:
selectNextPath();
function selectNextPath() {
/* https://stackoverflow.com/questions/60677948/photoshop-javascript-get-selected-pathitem */
var ref = new ActionReference();
ref.putProperty(charIDToTypeID("Prpr"), charIDToTypeID("TrgP"));
ref.putEnumerated(charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var desc = executeActionGet(ref);
desc.getInteger(charIDToTypeID("TrgP"));
// Relative path selection
try {
var currPath = desc.getInteger(charIDToTypeID("TrgP"));
$.writeln(currPath);
var incr = desc.getInteger(charIDToTypeID("TrgP"));
incr++;
$.writeln(incr);
app.activeDocument.pathItems[incr].select();
} catch (error) {}
}
Select Previous Path:
selectPrevPath();
function selectPrevPath() {
/* https://stackoverflow.com/questions/60677948/photoshop-javascript-get-selected-pathitem */
var ref = new ActionReference();
ref.putProperty(charIDToTypeID("Prpr"), charIDToTypeID("TrgP"));
ref.putEnumerated(charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var desc = executeActionGet(ref);
desc.getInteger(charIDToTypeID("TrgP"));
// Relative path selection
try {
var currPath = desc.getInteger(charIDToTypeID("TrgP"));
$.writeln(currPath);
var incr = desc.getInteger(charIDToTypeID("TrgP"));
incr--;
$.writeln(incr);
app.activeDocument.pathItems[incr].select();
} catch (error) {}
}
P.S. It would be nice to be able to do the same for channels as well, how to get channel id?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more