Scripting - Why certain Linked Smart Objects with Broken Link don't return "link" property?
Hello to all,
A quick scripting question:
Is there a way to determine which linked smart object with broken link will return link, and which won't?
This is the script I am running:
function s2t(str) { return stringIDToTypeID(str); }
function c2t(ch) { return charIDToTypeID(ch); }
function gather_smart_objects(){
var doc_ref = new ActionReference();
doc_ref.putIdentifier(s2t("document"), activeDocument.id);
var doc_descriptor = executeActionGet(doc_ref);
var layer_count = doc_descriptor.getInteger(s2t("numberOfLayers"));
var nr_of_smart_linked = 0;
var nr_of_smart_linked_with_missing_link = 0;
for(var layer_index = 1; layer_index <= layer_count; ++layer_index){
var layer_ref = new ActionReference();
layer_ref.putProperty(s2t("property"), s2t("layerKind"));
layer_ref.putIndex(s2t("layer"), layer_index);
var layer_descriptor = executeActionGet(layer_ref);
if(layer_descriptor.getInteger(s2t("layerKind")) == 5){
var layer_id_ref = new ActionReference();
layer_id_ref.putProperty(s2t("property"), s2t("layerID"));
layer_id_ref.putIndex(s2t("layer"), layer_index);
var layer_id_descriptor = executeActionGet(layer_id_ref);
var layer_id = layer_id_descriptor.getInteger(s2t("layerID"));
var action_ref = new ActionReference();
action_ref.putIdentifier(c2t('Lyr '), layer_id);
var action_descriptor = executeActionGet(action_ref);
var smart_object = action_descriptor.getObjectValue(s2t("smartObject"));
if (smart_object.hasKey(s2t("linked")) && smart_object.getBoolean(s2t("linked"))) {
++nr_of_smart_linked;
if (!smart_object.hasKey(s2t("link"))) {
++nr_of_smart_linked_with_missing_link;
}
}
}
}
alert(nr_of_smart_linked);
alert(nr_of_smart_linked_with_missing_link);
}
gather_smart_objects();
I have 121 linked smart objects with broken links in my psd.
nr_of_smart_linked evaluates to 121,
nr_of_smart_linked_with_missing_link evaluates to 22.
For this psd, I always get the same results, so it's not random, but I am lost as to understand why those 22 never give back the link.
Any help, even a direction in which to continue the investigation, would be much appreciated.
