Getting the path of linked (smart) object / PS Bug?
Hello All
i'm trying to read the path of the linked object/layer trough script. The path information seems to be available in the Layers properties panel (see screenshot 1).
When i try to use the command "reveal in finder" from within Photoshop, i do get an Error "Could not complete your request because of a program error."
So, i'm not able to use Scriptlistener to use the code for that.
Does anyone have a working AM code for this function available and knows why i do get this error on my side (on all psd documents i tried).
alert(app.activeDocument.activeLayer.filePath);
EDIT:
found this code that checks if there is a linked smart object and returns it's path.
Unfortunately i can't get it working like:
//Pseudocode:
If (activeLayer = linkedSmartobject)
{
var activeDesignPath = activeLayer.filePath;
} else {
// ignore ALL errors and continue (next layer will then be checked)
};
// Export/save as jpg to the root Folder of the linked smart object.
app.activeDocument.saveAs((new File(activeDesignPath + "/_Files Export/with GTO Background" +'/' + activeColor + ' ' + basename + ' ' + designDoc.activeLayer.name +'.jpg')),jpegOptions,true);
Original Script:
- if (app.documents.length)
- {
- var doc = app.activeDocument;
- for (var ilayer = 0; ilayer < doc.artLayers.length; ilayer++)
- {
- var layer = doc.artLayers[ilayer];
- if (layer.kind == LayerKind.SMARTOBJECT)
- {
- var ref = new ActionReference();
- ref.putIdentifier(charIDToTypeID('Lyr '), layer.id );
- var desc = executeActionGet(ref);
- var smObj = desc.getObjectValue(stringIDToTypeID('smartObject'));
- var localFilePath = smObj.getPath(stringIDToTypeID('link'));
- }
- }
- }
