Broken links destroy applied layer comp settings on linked objects (and trying to retrieve Comp Id via jsx script is broken too)

  • 1
  • Problem
  • Updated 2 years ago
  • (Edited)
Problem 1: Fixing broken linked smart objects or replacing the contents of a linked smart object will destroy the comp id settings applied to all instances of that smart link.

Case in point, I have a icon.psd file with several layer comps for different icons. This is linked into a wireframe boilerplate.psd in 8 instances. Each instance has a specific layer comp applied.

A designer duplicates the boilerplate project folder to a different place on their drive, somehow breaking all of the links (don't ask me how, it just does).

Re-linking the file causes all of the icons to revert to "Don't Apply Layer Comp" in their properties.

Scripting to the rescue! I found a way to get the applied comp id from the smart object through actiondescriptors in a .jsx script! Unfortunately, it is broken. The value is always and forever -1.

jsx:

Problem 1: Fixing broken linked smart objects or replacing the contents of a linked smart object will destroy the comp id settings applied to all instances of that smart link.

Case in point, I have a icon.psd file with several layer comps for different icons. This is linked into a wireframe boilerplate.psd in 8 instances. Each instance has a specific layer comp applied.

A designer duplicates the boilerplate project folder to a different place on their drive, somehow breaking all of the links (don't ask me how, it just does).

Re-linking the file causes all of the icons to revert to "Don't Apply Layer Comp" in their properties.

Scripting to the rescue! I found a way to get the applied comp id from the smart object through actiondescriptors in a .jsx script! Unfortunately, it is broken. The value is always and forever -1.

jsx:
// get application description object
var actref = new ActionReference();
actref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var appDesc = executeActionGet(actref);


// get layer count from app description
var layerCount = appDesc.getInteger(stringIDToTypeID("numberOfLayers"));


// process layers
for (var l = 0; l
try {
actref = new ActionReference();
actref.putIndex( charIDToTypeID( "Lyr " ), l)
layerDesc = executeActionGet(actref)
isSmartObject = layerDesc.hasKey(stringIDToTypeID('smartObject'))
if(isSmartObject)
{
// get object descriptors
var soDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObject'))
// var placedDesc = soDesc.getEnumerationValue(stringIDToTypeID('placed'))
var compsDesc = soDesc.getObjectValue(stringIDToTypeID('compsList'))


var name = layerDesc.getString(stringIDToTypeID('name'))
var id = layerDesc.getInteger(stringIDToTypeID('layerID'))
var fileReference = soDesc.getString(stringIDToTypeID("fileReference"))
var compID = compsDesc.getInteger(stringIDToTypeID('compID'))
var originalCompID = compsDesc.getInteger(stringIDToTypeID('originalCompID'))


$.writeln ("compID: " + compID);
$.writeln ("originalCompID: " + originalCompID);
}
}
catch(e){$.writeln(e.message)}
}

Outputs:
compID: -1
originalCompID: -1

But if I hook up generator.getDocumentInfo, I get this back:
{
"id": 19,
"index": 3,
"type": "layer",
"name": "raster blue",
"bounds": {
"top": 251,
"left": 112,
"bottom": 353,
"right": 302
},
"visible": true,
"clipped": false,
"generatorSettings": false,
"smartObject": {
"ID": "1f863200-620b-11e5-88ac-a70971fb3c91",
"placed": "472d38d4-620b-11e5-88ac-a70971fb3c91",
"antiAliasType": 16,
"type": 2,
"transform": [
112,
251,
302,
251,
302,
353,
112,
353
],
"comp": 1024141590 // <--- note the comp id here!
}
},

So now I am using a custom generator plugin and photoshop panel to relink smartlinks with comps applied. That seems like an intensely roundabout way to do things.

Solution 1: If the newly linked file has a matching layer id or comp name to the one in the properties... apply that one.

Solution 2: Properly expose the comp id in the actiondescriptor gotten off of the smart object via scripting

Please?

So now I am using a custom generator plugin and photoshop panel to relink smartlinks with comps applied. That seems like an intensely roundabout way to do things.

Solution 1: If the newly linked file has a matching layer id or comp name to the one in the properties... apply that one.

Solution 2: Properly expose the comp id in the actiondescriptor gotten off of the smart object via scripting

Please?
Photo of Max Johnson

Max Johnson, Champion

  • 399 Posts
  • 171 Reply Likes
  • frustrated.

Posted 2 years ago

  • 1
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 765 Reply Likes
In our current code we are adding the current LayerComp ID to the smart object descriptor, and it looks like that was added for CC 2014.
-1 is the value for "none selected"

The list of comps from the child document is not exposed anywhere at this time.
Photo of christoph pfaffenbichler

christoph pfaffenbichler, Champion

  • 1199 Posts
  • 159 Reply Likes
»In our current code we are adding the current LayerComp ID to the smart object descriptor«
Unfortunately this does not seem to work so I posted a bug report. 
https://feedback.photoshop.com/photoshop_family/topics/photoshop-javascript-bug-smartobject-s-compid...
Photo of Max Johnson

Max Johnson, Champion

  • 399 Posts
  • 171 Reply Likes
I did a test on a linked file and the OP problem has been fixed! I can break and re-link a linked smart object with a layer comp applied and it will retain that layer comp setting automatically (assuming it is the same psd that was linked originally, just in a different folder or different name). Haven't tried yet with extensive tests, but that solves the major issue.

The LayerComp ID still returns -1 for all layers, regardless of layer comp settings, but this particular thread has been solved.