Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Rename history state by script in Photoshop

Teilnehmer ,
Jul 19, 2021 Jul 19, 2021

Already posted this over on Photoshop Family, but maybe here's the better place?

 

I have the issue that when I double click the name of a history state, it becomes editable for a split second and then I can't type a new name. I don't know where this comes from and decided to write a little script that does this for me. But the script doesn't change the name either.

 

Maybe somebody can point me in the right direction here.

 

Here's the script:

#target photoshop 

var myDoc = app.activeDocument.name;
var currentHistoryStepName = app.activeDocument.activeHistoryState;
// alert( currentHistoryStepName );
var historyStateNameOnly = currentHistoryStepName.name.replace("HistoryState ", "");
// alert( historyStateNameOnly );
var pmt = prompt ('Type a new history state name', historyStateNameOnly, 'Rename History State');
alert( pmt );
app.activeDocument.activeHistoryState.name = pmt;

 

It all works well, I get the right name as an alert but the last line does not change the history step name. Maybe someone could quickly test this on a setup where they can rename the history state name by double clicking. Then I know it's because of my base problem that renaming it this way does not work for me.

THEMEN
Aktionen und Skripte
2.4K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines

correct answers 1 richtige Antwort

LEGENDE , Jul 19, 2021 Jul 19, 2021

A side effect you have I'm experiencing only when I have launched ExtendScript Toolkit with targeted Photoshop. To do by scripting that you want create new document and run this code:

 

sTT = stringIDToTypeID;

(ref1 = new ActionReference()).putClass(sTT('snapshotClass'));
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref1);
(ref2 = new ActionReference()).putProperty(sTT('historyState'), sTT('currentHistoryState'))
dsc.putReference(sTT('from'), ref2), dsc.putString(sTT('name'), nO = '
...
Übersetzen
Adobe
LEGENDE ,
Jul 19, 2021 Jul 19, 2021

Next time composing the post please use </> block when pasting the code 😉

Once assigned history state is unchangeable. Why did you think you can do it?

Slightly visible editable history state must be a bug? Rename history state by script

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Teilnehmer ,
Jul 19, 2021 Jul 19, 2021

Thanks and sorry for not posting code correctly!

 

I don't really follow what you mean.

 

When in the UI you can click the snapshot button in the history panel. Once that snapshot is created, normally you can double click it's name and rename it. For some reason this doesn;t work on my setup. Same for layer names. The name becomes editable for a split second and the goes back to fixed.

 

I want to do this because I am retouching photos using the history brush and therefore I run the Camera Raw Filter, for instance, to make the sky more blue by changing the temperature globally. Then I create a snapshot of that, go one step back and gradually paint the bluer sky in using the history brush.

 

Therefore I want to name the snapshots so I can remember which snapshot does what.

 

Attached a small video showing the issue in the UI.

 

Thanks!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Jul 19, 2021 Jul 19, 2021

A side effect you have I'm experiencing only when I have launched ExtendScript Toolkit with targeted Photoshop. To do by scripting that you want create new document and run this code:

 

sTT = stringIDToTypeID;

(ref1 = new ActionReference()).putClass(sTT('snapshotClass'));
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref1);
(ref2 = new ActionReference()).putProperty(sTT('historyState'), sTT('currentHistoryState'))
dsc.putReference(sTT('from'), ref2), dsc.putString(sTT('name'), nO = 'newOne')
dsc.putEnumerated(sTT('using'), sTT('historyState'), sTT('fullDocument'))
executeAction(sTT('make'), dsc);

(ref = new ActionReference()).putName(sTT('snapshotClass'), nO);
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref), executeAction(sTT('select'), dsc);

(ref1 = new ActionReference()).putProperty(sTT('historyState'), sTT('historyBrushSource'));
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref1);
(ref2 = new ActionReference()).putProperty(sTT('historyState'), sTT('currentHistoryState'))
dsc.putReference(sTT('to'), ref2), executeAction(sTT('set'), dsc)

 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Teilnehmer ,
Jul 19, 2021 Jul 19, 2021

Wow! Thank you! I can't even write a response as fast you you coded that up. Or did you record it and dumped the action as a script?

 

I get this problem with the renaming all the time. Tried running with no plugins and all the other sing and dances (except reinstalling...).

 

I added a prompt that asks for the initial name and - done! I am getting some older fashion prompt then when running your script without my dialog somehow. But that's a minor thing.

 

Mine: 

alexfurer_0-1626723841098.png

Your's (when running he script for a 2nd time):

alexfurer_1-1626724088792.png

 

Thank you!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Jul 19, 2021 Jul 19, 2021

You may create easily that code on your own (however is raw version), just use ScriptListener you find in Downloadable plug-ins & content | Photoshop

 

The reason you can't rename snapshot name (maybe also names from other pnales) can be caused by some plugin you use that disturbes your manual actions.

 

If you think my solution is correct, mark it so 😉

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Teilnehmer ,
Jul 19, 2021 Jul 19, 2021

Done! Thank you!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Jul 19, 2021 Jul 19, 2021
quote

I added a prompt that asks for the initial name and - done! I am getting some older fashion prompt then when running your script without my dialog somehow. But that's a minor thing.

 

Mine: 

alexfurer_0-1626723841098.png

Your's (when running he script for a 2nd time):

alexfurer_1-1626724088792.png

 

Thank you!


By @alex.furer

 

Prompt uses the native operating system windowing, so you get what you get on different versions of the same OS and between Mac and Win OS.

 

Using script UI one can achieve a more consistent GUI.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Teilnehmer ,
Jul 19, 2021 Jul 19, 2021
AKTUELL

True. I will eventually put that all in a larger script with more options like blending modes to be selected for the snapshot brushing, or launching ACR to do adjustments and maybe even incorporate luminosity mask to be triggered etc. etc. That's why I started going the scripting direction. Not only becaus e I have this UI bug.

 

Thanks to you all for helping me with this!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Jul 19, 2021 Jul 19, 2021

Just in case it wasn't obvious, the alternative is to hold down opt/alt when creating the history snapshot so that it is named as you wish when you create it.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Teilnehmer ,
Jul 19, 2021 Jul 19, 2021

I am running this as part of an action that creates a copy of the layer, rasterizes it and then set's up the initial snapshot and I don't think I can include the alt key in the action.

 

But this is a very usefull tip for every subsequent snapshot I create.

 

Thasnk you!

 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Jul 19, 2021 Jul 19, 2021
quote

I am running this as part of an action that creates a copy of the layer, rasterizes it and then set's up the initial snapshot and I don't think I can include the alt key in the action.

 

But this is a very usefull tip for every subsequent snapshot I create.

 

Thasnk you!

 


By @alex.furer

 

No, but if an interactive step is required, simply activate the modal control to the left of the action step. BTW I'm talking about history snapshots, not steps so I might have misunderstood. Anyway, Kukurykus has you sorted.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Teilnehmer ,
Jul 19, 2021 Jul 19, 2021

Tried that. Did not pop a dialog. But as you say, all sorted. But thanks for chiming in!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
LEGENDE ,
Jul 19, 2021 Jul 19, 2021

That's right. I changed code to shorter version.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines