Looking for some guidance on the script event manager. I have created an action that I run on images with specific export settings. I work with a lot of my assets in XD, and often will click on an image in XD and select the "edit in Photoshop" option, which then opens the document in PS. I see that it is possible to have "Open a document" as an event in the script manager, but I am wondering if it is possible to link opening a document from XD to Photoshop as an event that will automatically trigger the action. Thanks
Copy link to clipboard
The open event can run as script or an action. And a script can use actions and a action can use scripts. The thing is an open event will be triggered with every open document no matter what created the document. As far as I know Photoshop does not support a file type .XD. Can Adobe XD export some file format that Photoshop supports. If it does the Open Event handler must be able the distinguish if the file being open is one you want to process with your action. That would most likely require you to write a script to make that determination and do your action if it is to be processed..
XD does not transfer any special parameters to Photoshop, so the file opened as a result of "edit in Photoshop" cannot be distinguished from any other opening of the file. But you can use the file name or part of its path (for example, the name of the parent folder) to understand what exactly this file came from XD and, as a result, start the action you need. This is easily solved using scripts like that:
if (decodeURI(app.activeDocument.path).indexOf ('put your XD assets folder name here') != -1) app.doAction ('put here name of action', 'put here name of action set')
(change variables to your needs, save to *.jsx, put it to scripts folder, then add it to eventManager on document open event)
Thanks so much for your response! I've tried the script with the event manager but am still having trouble with it not triggering the action. I was wondering if the variable for the XD assets folder name needed to simply be the folder name (such as "XD Assets") or if it needs to be the full location/path of the folder on the machine.
Unfortunately, I can’t install XD on my computer to check that moment (error 191, I communicate with support for several weeks and so far they can’t find a solution for my case), but it seems that the files are opened not from the project folder, but from the temporary directory:
try to transfer the file to photoshop and execute the code
alert (decodeURI (app.activeDocument.path))
- it will show you the path from which the file is open.
Did you ever figure this out? I have exactly the same question - but want to use opening from Lightroom as a result of "edit in Photoshop"as an event trigger. "Open" works if I open the file from Photoshop, but not from Lightroom. Thanks.