Copy link to clipboard
Copied
Good year
I'm new to scripting and speak little English I hope to be clear.
I would like to create a panel that I change the opacity levels individually
as in this example
second and you can make it happen?

// change layers’ opacity via scrollbars;
// 2015, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
app.activeDocument.suspendHistory("opacity", "theDialog ()");
};
function theDialog () {
//////////////////////////////////////////
var theLayers = theLayerNames ();
////// create dialog for user-entry //////
var dlg = new Window('dialog', "layeropacity", undefined);
//////////////////////////////
dlg.layer = dlg.add('panel', undefined, "opacity");
dlg.layer.orientation = "column";
dlg
...Copy link to clipboard
Copied
Sorry and thanks for checking (back).
I’m out of ideas on this one so far …
Copy link to clipboard
Copied
I think its just an other bug in the new version of ScriptUI in CC 2015. The are many issues in CC 2015 I do not use it. Perhaps Adobe will do better in 2016 happy new year...
Copy link to clipboard
Copied
And a Happy New Year to you, too!
Copy link to clipboard
Copied
Sorry if I take advantage of your kindness
you could insert a checkbox before e after to see the changes.
Copy link to clipboard
Copied
I suppose there are (at least) two possible approaches
• collect the current settings to be able to, if the preview is turned off, re-apply the original ones and then, if the preview is turned on, re-apply the edited settings
• create a "Snapshot" and insert/remove that as a Layer
The actual History Snapshot will not work out currently as the History is suspended, not suspending the History would cause every change in the dialog to register in the History.
Maybe you should try to implement the changes when you have a little more experience with Photoshop Scripting.
Copy link to clipboard
Copied
I realized with scripting'm having a little 'difficulty is why I ask for help, reading your code much I learn things from books and much more' difficult to understand,
I thought about doing something like that was more 'easy, but you gave me to understand that it is very difficult.
I hope someone reads the discussion and help me in this.
Again thank you for everything
Copy link to clipboard
Copied
but you gave me to understand that it is very difficult.
No, it is feasible but as this is just a Script and no proper plugin the methods to achieve this are a little roundabout.
One approach would be to use something like is currently being used if the dialog gets cancelled
if (myReturn != 1) {
for (var a = 0; a < theLayers.length; a++) {
setOpacityByID (theLayers[1], theLayers[2])
}
};
to reset the original opacity values for the Layers on the click of a checkbox and do the "reverse" if it is unchecked.
Copy link to clipboard
Copied
I understood this thing and difficult
even if you create a level snapshot with a checkbox that enables and disables this can be done.
Copy link to clipboard
Copied
If you have a specific question maybe you should start a new thread.
This one is a not of a nuisance to me because all my recent posts here seem to have triggered moderation …
Copy link to clipboard
Copied
I actually do not see why you would even want this script. For you have scrubby slider in the layers palette for layers opacity in the first place..
The only benefit I see the script provides is you can make many opacity changes and not add history states because while the script is in control it turns off history state recording. However by the same token when the script is running all you can do is change layers opacity all other Photoshop features are not avaible for use.
Copy link to clipboard
Copied
Thank you again
if I have any questions I will open 'another topic
I thank sincerely them both for as long as I have dedicated.
Copy link to clipboard
Copied
I was looking at te examples in the ExtendScript Toolkit SDK ColorPicker.jsx and ColorSelector.jsx the ScriptUI sliders they use work fine in CC 2015 however the controls in ColorSelector.jsx Dialog do not work. So you may want to change scroll bars to sliders.

Copy link to clipboard
Copied
// change layers’ opacity via scrollbars;
// 2015, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
app.activeDocument.suspendHistory("opacity", "theDialog ()");
};
function theDialog () {
//////////////////////////////////////////
var theLayers = theLayerNames ();
////// create dialog for user-entry //////
var dlg = new Window('dialog', "layeropacity", undefined);
//////////////////////////////
dlg.layer = dlg.add('panel', undefined, "opacity");
dlg.layer.orientation = "column";
dlg.layer.preferredSize = [300, 50];
// populate panel;
for (var m = 0; m < theLayers.length; m++) {
dlg.layer.add('statictext', undefined, theLayers
dlg.layer.add('scrollbar', undefined, theLayers
var thisIndex = dlg.layer.children.length - 1;
dlg.layer.children[thisIndex].preferredSize = [256,20];
dlg.layer.children[thisIndex].helpTip = String(m);
//////////////////////////////
// if scrolled;
dlg.layer.children[thisIndex].onChange = function () {
setOpacityByID (theLayers[Number(this.helpTip)][1], Math.round(this.value));
app.refresh();
};
};
//////////////////////////////
// build- and cancel-button;
dlg.cancelOk = dlg.add('panel', [12,495,308,550], "");
dlg.cancelOk.buildBtn = dlg.cancelOk.add('button', [10,10,141,40], 'OK', {name:'ok'});
dlg.cancelOk.cancelBtn = dlg.cancelOk.add('button', [149,10,280,40], 'Cancel', {name:'cancel'});
dlg.center();
var myReturn = dlg.show ();
//////////////////////////////
// reset if canceled;
if (myReturn != 1) {
for (var a = 0; a < theLayers.length; a++) {
setOpacityByID (theLayers[1], theLayers[2])
}
};
$.gc();
};
////////////////////////////////////
function theLayerNames () {
// the file;
var myDocument = app.activeDocument;
// get number of layers;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));
// process the layers;
var theLayers = new Array;
for (var m = 0; m <= theNumber; m++) {
try {
var ref = new ActionReference();
ref.putIndex( charIDToTypeID( "Lyr " ), m);
var layerDesc = executeActionGet(ref);
var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));
var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));
// if not layer group collect values;
if (layerSet != "layerSectionEnd" && layerSet != "layerSectionStart" && isBackground != true) {
var theName = layerDesc.getString(stringIDToTypeID('name'));
var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));
var theOpacity = layerDesc.getInteger(stringIDToTypeID('opacity'));
theLayers.push([theName, theID, theOpacity])
};
}
catch (e) {};
};
return theLayers
};
////// set opacity //////
function setOpacityByID (theID, theOpacity) {
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var idLyr = charIDToTypeID( "Lyr " );
var ref1 = new ActionReference();
ref1.putIdentifier( idLyr, theID );
desc2.putReference( idnull, ref1 );
var idT = charIDToTypeID( "T " );
var desc3 = new ActionDescriptor();
desc3.putUnitDouble( charIDToTypeID( "Opct" ), charIDToTypeID( "#Prc" ), Math.round(theOpacity/2.55) );
desc2.putObject( idT, idLyr, desc3 );
executeAction( idsetd, desc2, DialogModes.NO );
};
Copy link to clipboard
Copied
I still find if you quickly move a scrollbar's slider side to side the script scrollbar's end arrows will vanish using Photoshop CC 2015 and CC 2015.5 and Photoshop will stop responding. The Windows Task manager will show the Photoshop is not responding but is using 5% of my machine CPU power. The Task Manager must be used to terminate Photoshop. The Script work well in Photoshop versions prior the CC 2015.

Copy link to clipboard
Copied
I've quit using scrollbars and now always use plain sliders – scrollbars can do weird things on CC2015.x (on Mac at least), like you move the whole Dialog and the scrollbar's "bar" (cursor, thumb, how do you call that in english?) keeps in the same position relative to the whole display.
Copy link to clipboard
Copied
Yes there are some differences between OS versions and platforms differences..
Copy link to clipboard
Copied
Yes in that version the mod you posted works. I must be using the first or second script posted.
CC 2015 ScriptUI has problems and will loop and hang Photoshop. When you play with this scripts sliders too much.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now