• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

Is it possible the script to create a displacement map without the need to load a .psd file

Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

Hello,

 

According to my question in this thread I will repost it again in a new thread.

 

The question answered by Chuck Uebele with the following code:

 

#target photoshop
var doc = activeDocument;
var curLayer = doc.activeLayer;
var disMap = doc.layers.getByName('displace test');
doc.activeLayer = disMap;

editSO ();

var disDoc = activeDocument;
var disFile = disDoc.path +'/' + disDoc.name;
app.activeDocument = doc;
doc.activeLayer = curLayer;

editDis (disFile);
alert(editDis);

function editSO(){
	var idplacedLayerEditContents = stringIDToTypeID( "placedLayerEditContents" );
	var desc3 = new ActionDescriptor();
	executeAction( idplacedLayerEditContents, desc3, DialogModes.NO );   
}

function editDis(dMapFile){
	var idsetd = charIDToTypeID( "setd" );
	var desc9 = new ActionDescriptor();
	var idnull = charIDToTypeID( "null" );
	var ref3 = new ActionReference();
	var idfilterFX = stringIDToTypeID( "filterFX" );
	ref3.putIndex( idfilterFX, 1 );
	var idLyr = charIDToTypeID( "Lyr " );
	var idOrdn = charIDToTypeID( "Ordn" );
	var idTrgt = charIDToTypeID( "Trgt" );
	ref3.putEnumerated( idLyr, idOrdn, idTrgt );
	desc9.putReference( idnull, ref3 );
	var idfilterFX = stringIDToTypeID( "filterFX" );
	var desc10 = new ActionDescriptor();
	var idFltr = charIDToTypeID( "Fltr" );
	var desc11 = new ActionDescriptor();
	var idHrzS = charIDToTypeID( "HrzS" );
	desc11.putInteger( idHrzS, 40 );
	var idVrtS = charIDToTypeID( "VrtS" );
	desc11.putInteger( idVrtS, 40 );
	var idDspM = charIDToTypeID( "DspM" );
	var idDspM = charIDToTypeID( "DspM" );
	var idStrF = charIDToTypeID( "StrF" );
	desc11.putEnumerated( idDspM, idDspM, idStrF );
	var idUndA = charIDToTypeID( "UndA" );
	var idUndA = charIDToTypeID( "UndA" );
	var idRptE = charIDToTypeID( "RptE" );
	desc11.putEnumerated( idUndA, idUndA, idRptE );
	var idDspF = charIDToTypeID( "DspF" );
	desc11.putPath( idDspF, new File( dMapFile ) );
	var idEmbF = charIDToTypeID( "EmbF" );
	desc11.putBoolean( idEmbF, true );
	var idDspD = charIDToTypeID( "DspD" );    
	var idDspl = charIDToTypeID( "Dspl" );
	desc10.putObject( idFltr, idDspl, desc11 );
	var idfilterFX = stringIDToTypeID( "filterFX" );
	desc9.putObject( idfilterFX, idfilterFX, desc10 );
	executeAction( idsetd, desc9, DialogModes.NO );
}

 

is throwing the following error 8800 whenever I load the script:

The object "filter effects 1 of current layer" is not currently available.

 

As far as I can understand, the code does create in {USER}\AppData\Local\Temp a file named displace test.psb as from the example in this thread and after that it throws the above mentioned error.

 

Is it possible the script to create a displacement map from the SmartObject without the need to load a .psd file every time a parameter value is to be changed?

 

What am I doing wrong here if somone could provide me with an answer?

 

Thank you,

Damian

TOPICS
Actions and scripting , Windows

Views

8.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Valorous Hero , Jun 10, 2021 Jun 10, 2021

Probably some of us do not understand something.

 

I have questions. How did you create the smart object, why is it in PSB format?

To convert a smart object to PSD format, you have to open the smart object, save the document somewhere in PSD format, close the smart object, replace its content with the saved file.

Or create a smart object by executing the Place command of the required PSD file.

 

Have you taken these steps?

Votes

Translate

Translate
Community Expert , Jun 12, 2021 Jun 12, 2021

The displacement file in the Smart Object need to be a psd file and not a PSB file.

Votes

Translate

Translate
Adobe
Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

Oh that would be life savor to have a panel to actually use displacement map as any other normal program and not this archaich way of saving a file to psd and not having any real time feedback. Its a real problem, that Adobe it seems has no intention of fixing and or upgrading.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

Hello Milan_Smith,

 

The script provided by Chuck Uebele should provide exactly what we are looking for, but the problem is that I am still confused and don't know what exactly the error means that I have pointed above. I am sure that some folks here are ready to help with what is going on with the error or to provide more detailed instructions on how to solve the problem though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

I did not delve into and did not check.
But maybe the problem is that you have a PSB file, but you need a PSD.
Replace the content of the smart object with a PSD file.
 
 
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

Hello r-bin,

The script has very odd behaviour. First I have to load the displacement map .psd file, then, after executing the script, it saves a .psb file in {USER}\AppData\Local\Temp. After manually deleting that file and reloading the script, everything works fine at first glance, but after analyzing the result, it remembers the last state even if I change the .psd file that contains the reference for displacement. I find no problem in the script itself as my knowledge allows, but my suspiciousness is in the how Photoshop handles with CEP.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

Probably some of us do not understand something.

 

I have questions. How did you create the smart object, why is it in PSB format?

To convert a smart object to PSD format, you have to open the smart object, save the document somewhere in PSD format, close the smart object, replace its content with the saved file.

Or create a smart object by executing the Place command of the required PSD file.

 

Have you taken these steps?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

I have tried exactly the same steps as per your description but without success.

 

My guess is disDoc.name holds the information of the opened Smart Object and tries to edit .psb file in the {USER}\AppData\Local\Temp but also without success.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

OMG!

Describe your actions step by step.

Why are you going into the Temp folder and touching the temp file?

Do not try to open or delete it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

Finally the mystery was solved with the "Place Embedded" command as you pointed... after I found it of course.

 

First, I have created a psd that is the displacement map, second, created a new psd where the Displace filter was applied as per Chuck Uebele's instructions and third I have used the most enlighting and gorgeous chicken of all, the "Place Embedded" command, but as I had a brainfart at that time I was seeing double and did nothing with her.

 

Now everything works fine.

 

Thanks to both of you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

LATEST

R-bin the reason the SO file is opened, which is in the temp folder, is just to get the path, so that the displace filter can use that file to make changes to the displacement filter. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

I haven't tried this out, but it might be that the displacement map file isn't exactly the same size as your target file. They have to be the same.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

Ok, I just ran the script again. You have to have your target layer have a displacement map already applied to the target layer. Then it will apply the embedded displacement map.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

I have applied the displacement map on the target layer that is a Smart Object, the second layer is also a Smart Object named "displace test".

 

By applying the script now I get the following error:

"Could not complete the command because the file is not compatible with this version of Photoshop."

In {USER}\AppData\Local\Temp I find that the script opens the second layer named as displace test.psb as in your example and tries to make changes and this is where throws the error I guess.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2021 Jun 12, 2021

Copy link to clipboard

Copied

The displacement file in the Smart Object need to be a psd file and not a PSB file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines