Copy link to clipboard
Copied
Hi, I am totally new to scripting. I thought I would try to work out something simple first, to get my feet wet. But I can't seem to understand how to make the script do what I want. Essentially, I just need it to see if there is a work path in the document, and, if so, save it as a normal path. Any help would be appreciated.
If it matters, I have been trying to do this in Java. I may give Applescript a shot later.
Thanks,
Hi tJohnson,
Try this code...
activeDocument.pathItems.getByName("Work Path").name="Path 1";
- yajiv
I would wrap that code in a try/catch block, as if there isn't a workpath, an error would be thrown. You could also change the name to:
.name = 'path ' + activeDocument.pathItems.length
in an attempt to auto name the path, so if you happen to already have a Path 1, the dialogbox won't come up to have you rename the path.
Copy link to clipboard
Copied
Hi tJohnson,
Try this code...
activeDocument.pathItems.getByName("Work Path").name="Path 1";
- yajiv
Copy link to clipboard
Copied
I would wrap that code in a try/catch block, as if there isn't a workpath, an error would be thrown. You could also change the name to:
.name = 'path ' + activeDocument.pathItems.length
in an attempt to auto name the path, so if you happen to already have a Path 1, the dialogbox won't come up to have you rename the path.
Copy link to clipboard
Copied
Cool, I didn't know that's so easy, so I always used Action Managet to change name of paths 😕
Copy link to clipboard
Copied
Thanks folks. Between the two of you I was able to get it to do exactly what I wanted (and a bit more, even).
In case anyone else comes along looking for the same bit of code, here's what worked for me:
#target photoshop
app.bringToFront();
try {
activeDocument.pathItems.getByName("Work Path").name="Path " + activeDocument.pathItems.length;
}
catch (Exception) {}
Copy link to clipboard
Copied
Unfortunately for me right now, when I rename the Work Path in a document I'm processing, it for some reason removes the 'path' line of the path. I'm going to have to try utilizing an action to perform the 'save path' command.
Copy link to clipboard
Copied
UPDATE: I was able to fix this by using the PathItem.select() method to ensure the path is first selected in the Paths panel before renaming. Then the path content stays. However I discovered another issue which caused the path to be cleared due to my follow-up action which has to run (it's an action from somebody else). In order to fix this new issue I used the PathItem.deselect() method which made the path not be cleared by whatever the follow-up action does.
Copy link to clipboard
Copied
So maybe if it's not your action, then that other one deletes path only when it's selected 🙂