Yes, that was the case and this is the behaviour what I'm after (I just didn't knew how to do it).Kukurykus wrote: ↑Sun Jan 03, 2021 12:55 pm That has nothing to do with Smart Object, you simply have not unchecked 'Always Create Smart Objects When Placing' in General Preferences.
You can keep Smart Objects though if later you want to relink them to other .pngs, or simply replace embedded content.
All smart objects will refresh at once only when first they all were linked to same file, so are duplicates of each other.
I've incorporated these functions to your code, so now all the imported/generated layers are smart objects linked to the corresponding image.
Code: Select all
// Edit->Preferences->General->[?] Always create smart objects when placing
// Use [Ctrl+K] to get to the preferences menu
function placeRasterSmartObjectPreference(bool)
{
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(cTID('Prpr'), cTID('GnrP'));
ref1.putEnumerated(cTID('capp'), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putBoolean(sTID("placeRasterSmartObject"), bool);
desc1.putObject(cTID('T '), cTID('GnrP'), desc2);
executeAction(cTID('setd'), desc1, DialogModes.NO);
}; // function placeRasterSmartObjectPreference
// Relink to File
// run with: placeRasterSmartObjectPreference(true);
function AcLyrRelinkToFile(fpath)
{
if (app.activeDocument.activeLayer.kind != LayerKind.SMARTOBJECT) return;
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var des = new ActionDescriptor();
des.putPath(cTID('null'), new File(fpath));
executeAction(sTID('placedLayerRelinkToFile'), des, DialogModes.NO);
}; // function AcLyrRelinkToFile
Was just curious about it, looks like theres a workaround for everything.

By 'placing method' I understand the technique you used in your code?
How is that done manually and how would look with using DOM?