Hi all, I have working script which replaces smart objects with the new image, and it is working as expected. function someFunction(){ //some code changeSOContent(); } function changeSOContent(){ var myDocument = currentDocument; // some code var imageGroup = myDocument.layerSets.getByName('images-group'); var imageSmartObj = imageGroup.artLayers.getByName('image-so'); var imageFiles = Folder(imgDirPath).getFiles(/\.(jpg|psd|png)$/i); for (var i = 0; i < imageFiles.length; i++) { imageSmartObj = replaceContents(imageFiles, imageSmartObj); myDocument.saveAs((new File(destinationFolder + "/" + theName + ".jpg")), jpgopts, true); } } function replaceContents(newFile, theSO) { app.activeDocument.activeLayer = theSO; var idplacedLayerReplaceContents = stringIDToTypeID("placedLayerReplaceContents"); var desc3 = new ActionDescriptor(); var idnull = charIDToTypeID("null"); desc3.putPath(idnull, new File(newFile)); var idPgNm = charIDToTypeID("PgNm"); desc3.putInteger(idPgNm, 1); executeAction(idplacedLayerReplaceContents, desc3, DialogModes.NO); return app.activeDocument.activeLayer; } But I want to add progress bar while script is doing the job. So I try like this function someFunction(){ app.doForcedProgress("Progress bar start.", "changeSOContent()"); } function changeSOContent(){ var myDocument = currentDocument; //some code var imageGroup = myDocument.layerSets.getByName('images-group'); var imageSmartObj = imageGroup.artLayers.getByName('image-so'); for (var i = 0; i < imageFiles.length; i++) { var canContinue = app.doProgressSubTask(i, imageFiles.length, "updateProgress()"); if (!canContinue) return; function updateProgress(){ app.changeProgressText("Current image: " + i + ""); } imageSmartObj = replaceContents(imageFiles, imageSmartObj); myDocument.saveAs((new File(destinationFolder + "/" + theName + ".jpg")), jpgopts, true); } } function replaceContents(newFile, theSO) { app.activeDocument.activeLayer = theSO; var idplacedLayerReplaceContents = stringIDToTypeID("placedLayerReplaceContents"); var desc3 = new ActionDescriptor(); var idnull = charIDToTypeID("null"); desc3.putPath(idnull, new File(newFile)); var idPgNm = charIDToTypeID("PgNm"); desc3.putInteger(idPgNm, 1); executeAction(idplacedLayerReplaceContents, desc3, DialogModes.NO); return app.activeDocument.activeLayer; } But I've got error that said General Photoshop error Occured. This functionality may not be available in this version of Photoshop. for the executeAction(idplacedLayerReplaceContents, desc3, DialogModes.NO); Somehow, when I call function which contains executeAction() script breaks whit this error. When I comment out everything in replaceContents(), everything goes smoothly. Of course, smart object hasn't being replaced, but rest of the code runs without error I've try to figure it out for days, but with no success, because there is no enough search results for doProgress(). Photoshop version is CC 2017 I've also tried solution with Window palette with win.update(); but I've got flickering and is not working as expected. Can anybody help me about this? Thanks
... View more