Skip to main content
gokug95470003
New Participant
November 25, 2020
Question

Smart object in Psd file can not open

  • November 25, 2020
  • 3 replies
  • 872 views

Why Smart object files can't edit in photoshop
When I double click files it opens in the media app

 

This topic has been closed for replies.

3 replies

JJMack
Adobe Expert
November 29, 2020

How did you create the Smart object layer in your Mockup template https://community.adobe.com/havfw69955/attachments/havfw69955/photoshop/488164/1/Wall%20Interiors.psd 

That smart object layer's does not fully open when a script uses Layer>SmartsObjects>Edit content

 

I have tried to create other Smart Object Layer that also do not fully open with the menu item "placedLayerEditContents"   the internals name.  Adobe Photoshop Plug-in Scriptlistener record a 

"placedLayerEditContents" step a history step and an open work file step for your smart object  the plug-in only records a "placedLayerEditContents" step and a history step for all the other smart object layers I have tried.    So I'm very curious as to how you created that smart Object.   I find the with the code I added to handle your smart object later.  That while object  RAW file and Vector fule will Open in ACR and  AI not pgotoshop so My Script would loose control.  The Code I added for you object would regain control when  ACR and AI finish. The Work vector File will be imported by Photoshop  with the open and the Raw work file also seem to open in Photoshop.  That may open some possibility for me to me to support Raw and Vector objects.  I need to be ables to make  ACR and AI to just terminate or make them a none operational while my script is running but still have "placedLayerEditContents"  create the work file for the object.

 

So how did yout create your Smar Object layer with this content?

 

JJMack
JJMack
Adobe Expert
November 25, 2020

In my  Mockup scripts I use a function I create from ScriptListener action manager code to open smart object layer's object. 

 

 

////// open smart object //////
function openSmartObject (theLayer) {
	if (theLayer.kind == "LayerKind.SMARTOBJECT") {
		// =======================================================
		var idplacedLayerEditContents = stringIDToTypeID( "placedLayerEditContents" );
			var desc2 = new ActionDescriptor();
		executeAction( idplacedLayerEditContents, desc2, DialogModes.NO );
	};
	return app.activeDocument
};

 

 

This code does not Open your smart object layer's object and it also does not throw an error.  This messes up my script coding. The reason seem related to your object contains a vector smart object. 

 

When  I look at what the Scriptlistener records when I open your smart object layer's object is not only the  "placedLayerEditContents"  Photoshop command there is an additional Open File command for the temp Work Document Photoshop created in temp space. That open command is not recorded if I replace vector smarts object  with a reasterize version of the layer.   Here is the code that gets recorded when there is a vector smart object.

 

 

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

// =======================================================
var idhistoryStateChanged = stringIDToTypeID( "historyStateChanged" );
    var desc696 = new ActionDescriptor();
    var idDocI = charIDToTypeID( "DocI" );
    desc696.putInteger( idDocI, 3260 );
    var idIdnt = charIDToTypeID( "Idnt" );
    desc696.putInteger( idIdnt, 3262 );
    var idNm = charIDToTypeID( "Nm  " );
    desc696.putString( idNm, """Open""" );
    var idhasEnglish = stringIDToTypeID( "hasEnglish" );
    desc696.putBoolean( idhasEnglish, true );
executeAction( idhistoryStateChanged, desc696, DialogModes.NO );

// =======================================================
var idMRUFileListChanged = stringIDToTypeID( "MRUFileListChanged" );
    var desc697 = new ActionDescriptor();
    var iddontRecord = stringIDToTypeID( "dontRecord" );
    desc697.putBoolean( iddontRecord, true );
    var idforceNotify = stringIDToTypeID( "forceNotify" );
    desc697.putBoolean( idforceNotify, true );
executeAction( idMRUFileListChanged, desc697, DialogModes.NO );

// =======================================================
var idOpn = charIDToTypeID( "Opn " );
    var desc698 = new ActionDescriptor();
    var iddontRecord = stringIDToTypeID( "dontRecord" );
    desc698.putBoolean( iddontRecord, false );
    var idforceNotify = stringIDToTypeID( "forceNotify" );
    desc698.putBoolean( idforceNotify, true );
    var idnull = charIDToTypeID( "null" );
    desc698.putPath( idnull, new File( "C:\\Users\\jjmac\\AppData\\Local\\Temp\\Rectangle 1.psb" ) );
    var idDocI = charIDToTypeID( "DocI" );
    desc698.putInteger( idDocI, 3260 );
executeAction( idOpn, desc698, DialogModes.NO );

 

 

It look like the scriptlistener records a history state change  after the placedLayerEditContent which which does not seem to be required when there is not vector object for I just did not use it and the placedLayerEditContent  which I did used works when there is no vector object layer in the object.

The "MRUFileListChanged" and "Opn " commands are not recorded by the scriptlistener whet there is no vector object.  I do not know how one would retrieve the work file full pate Photoshop create in temp space for the placedLaeyerEditContent Command  

"C:\\Users\\jjmac\\AppData\\Local\\Temp\\Rectangle 1.psb" 

 

I can catch when the Object does not open with the  placedLayerEditContent  for now.   I'll look at r-bin code the gets object file extension I may be able to  see if the file is created in temp and open it

 

JJMack
JJMack
Adobe Expert
November 25, 2020

Looking at r-bin code I saw I could get the file name and extension the Photoshop would create in temp space. I'm a Windows user so I know where Windows users temp space as it turned out  the  "placedLayerEditComtents" command I use to open the smart object did create the object's work file but did not open it.   So I developed the file path and tested for its existence and  I was able open it. So I will update my collage and mockup toolkit scripts  to be able to Support that kind of object.  Once I update the smart object  the "placedLayerEditComtents" command opened the updated object for  the rest of the batch. For my edit process clears out the original object structure and fits the replacement to the object canvas.   So only the first replacement is opened by my new code.  I do not know if my Hack will work on a Mac.  For I is the Windois URI convertion for user temp space  "~/AppData/Local/Temp/". The code will most like wind you generating a message  like  "[Artlayer Layer Name] Smart Object Did not Open" on a Mac.

 

////// open smart object //////
function openSmartObject (theLayer) {
	current = app.activeDocument;
	if (theLayer.kind == "LayerKind.SMARTOBJECT") {
		var idplacedLayerEditContents = stringIDToTypeID( "placedLayerEditContents" );
			var desc2 = new ActionDescriptor();
		executeAction( idplacedLayerEditContents, desc2, DialogModes.NO );
	};
	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( "~/AppData/Local/Temp/" +  name); 
		if (workFile.exists) app.open(File(workFile));
		if ( current == app.activeDocument) {	
			throw theLayer + " Smart Object Did not Open";
			}
	}
	return app.activeDocument
};

 

JJMack
gokug95470003
New Participant
November 26, 2020

Thank you very much

gokug95470003
New Participant
November 25, 2020

This Video. but I send to my friend test he says it the not problem

https://drive.google.com/file/d/1AsmfMjwSSZV6rcnkPPtQavBwmUVnQH3C/view?usp=sharing 

JJMack
Adobe Expert
November 25, 2020

Make sure the file extension .psb is associated with photoshop as its default application.

JJMack
gokug95470003
New Participant
November 25, 2020

Ok,

I think I see the problem. Thank you very much