Skip to main content
Known Participant
September 3, 2021
Question

Please help, error when placedLayerEditContents.

  • September 3, 2021
  • 2 replies
  • 2833 views

Hello,

when i use code bellow

'app.activeDocument.activeLayer = layer
executeAction( sTT('placedLayerEditContents'), undefined, DialogModes.NO );'

 

error occured: The command edit content is not currently available.

what is wrong??

 

Thanks so much

This topic has been closed for replies.

2 replies

JJMack
Community Expert
Community Expert
September 3, 2021

You also need to be careful in you script when it come to  opening a smart object layer's object to edits its content.  If the layer's object  is a vector image  or a camera raw image the  object will open in application  or Plug-in that processes those images formats  AI or ACR your Photoshop Script's next statement would be executed after AI of ACR  is done the object would or would not have been updated the  object work document would not be open in Photoshop.  I use code that  r-bin posted to test the smart object and bypass vector and Raw object in my mockup scripts for Photoshop does not  have  support for vector and raw image formats.   

 

I have also has issues where the Object work file created in temp by Photoshop did not open in Photoshop  I had the add some code to handle the problem if/when it occured.

 

////// open smart object //////
function openSmartObject (theLayer) {
	current = app.activeDocument;
	if (theLayer.kind == "LayerKind.SMARTOBJECT") {
		runMenuItem(stringIDToTypeID('placedLayerEditContents'));
		if ( current == app.activeDocument) {
			try {         
				var r = new ActionReference();     
				r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("smartObject"));  
				r.putIdentifier(stringIDToTypeID("layer"), theLayer.id);  
				var name = executeActionGet(r).getObjectValue(stringIDToTypeID("smartObject")).getString(stringIDToTypeID("fileReference"));         
				}  
			catch (e) { throw theLayer + " Smart Object Did not Open"; }  
			var workFile = new File(Folder.temp + "/" +  name);  // May work for both Windows and Mac
			if (workFile.exists) app.open(File(workFile));
			if ( current == app.activeDocument) throw theLayer + " Smart Object Did not Open";
		}
	}
	return app.activeDocument
};

 

JJMack
Stephen Marsh
Community Expert
Community Expert
September 3, 2021

These work for me:

 

var idplacedLayerEditContents = stringIDToTypeID( "placedLayerEditContents" );
    var desc3536 = new ActionDescriptor();
executeAction( idplacedLayerEditContents, desc3536, DialogModes.NO );

 

or

 

app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
hui5C21Author
Known Participant
September 3, 2021

thanks,but not for me ,still error. this is my code:

function _checkLayers(layers, expFile)
{
for(var i = 0 ; i < layers.length ; i++)
{
var layer = layers[i];

if ( layer.visible == false ) {
continue
}
if(layer.typename == 'ArtLayer')
{
if ( layer.bounds[0] < layer.bounds[2] && layer.bounds[1] < layer.bounds[3] )
{
app.activeDocument.activeLayer = layer
_trySaveImage( expFile )
}
}
else
{
_checkLayers(layer.layers, expFile);
}
}
}

function _trySaveImage( expFile ) {
var layer = app.activeDocument.activeLayer
var fn = _getLayerName(layer)
var filename = _getUniquePngName(fn)//create unique png name
_writeData(layer, filename, expFile);//export layer data
if ( layer.kind != LayerKind.TEXT && !_isCommonPng(fn))
{
app.activeDocument.activeLayer = layer
var desc3536 = new ActionDescriptor();
executeAction( sTT('placedLayerEditContents'), desc3536, DialogModes.NO );
_saveImage(filename);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
allnames.push( filename )
}
}

 

_checkLayers(app.activeDocument.layers,expFile).

Legend
September 3, 2021

где? файл в упор не вижу. каретка таким макаром записывается как видимый символ, но ошибки не вызывает, но твой скрипт интересен. ломает смарт-рбект на прочь, даже для ручного редактирования. потом разберусь. сейчас некогда.


Показалось (с телефона). 

 

1 сентября? 🙂

 

Да, можно лочить смарт-объекты. Правда я это как-то обходил (запорол кучу слоев, потом разгребал как их отредактировать). Пару лет назад было, не помню что сделал в итоге.