• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Suppress Dialog when Scripting Blur Gallery Changes

Community Beginner ,
Jul 24, 2022 Jul 24, 2022

Copy link to clipboard

Copied

Hi,

 

I'm writing a script that modifies the current blur amounts of a Blur Gallery smart filter after it's been applied (similar to the functionality of Layer Style>scale effects). Is there a way to script changes to a Blur Gallery smart filter without launching the Blur Gallery UI? My script uses:

executeAction( s2t( "set" ), descriptor, DialogModes.NO );
to make the changes. However, it still launches the Blur Gallery UI. I'm running it over multple smart filter instances on multiple layers and would prefer not to have to hit enter to apply each Blur Gallery change. Any help would be much appreciated.
 
Thanks!
Jeremy
TOPICS
Actions and scripting

Views

377

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
Adobe
Community Expert ,
Jul 30, 2022 Jul 30, 2022

Copy link to clipboard

Copied

I doubt that I myself would be able to rectify this exact problem but don’t you think posting the actual code would be useful? 

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 Beginner ,
Jul 30, 2022 Jul 30, 2022

Copy link to clipboard

Copied

Thanks for responding. Here's a "simplified" version of the code. It works. However, as I mentioned above, it still launches Blur Gallery UI. Any advice would be much appreciated:

 

var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var doc = activeDocument;
var count = 0;
var scaleFactor = prompt("Please enter scale percentage: ", 100) / 100;
var layerDescriptor = new ActionDescriptor();

layerDescriptor = getDescriptor("layer");
scaleBlurGallery(layerDescriptor,0);

function scaleBlurGallery(layerDescriptor, index){
var filterDescriptor = layerDescriptor.getObjectValue(s2t("smartObject")).getList(s2t("filterFX")).getObjectValue(index).getObjectValue(s2t("filter"));
var referenceRectDescriptor = layerDescriptor.getObjectValue(s2t("smartObject")).getList(s2t("filterFX")).getObjectValue(index).getObjectValue(s2t("filter")).getObjectValue( s2t( "referenceRect" ), s2t( "rectangle" ));
var blurbWidgetList = filterDescriptor.getList(s2t("blurbWidgetList"));

var blurbType = filterDescriptor.getBoolean(s2t("blurbType"));
var versionMajor = filterDescriptor.getInteger(s2t("versionMajor"));
var versionMinor = filterDescriptor.getInteger(s2t("versionMinor"));
var versionMinor = filterDescriptor.getInteger(s2t("versionMinor"));
var top = referenceRectDescriptor.getInteger(s2t("top"));
var left = referenceRectDescriptor.getInteger(s2t("left"));
var bottom = referenceRectDescriptor.getInteger(s2t("bottom"));
var right = referenceRectDescriptor.getInteger(s2t("right"));
var blurbOpenPanel = filterDescriptor.getInteger(s2t("blurbOpenPanel"));
if (filterDescriptor.hasKey(s2t("blurbGeneralBlurEffectApplied"))){
var blurbGeneralBlurEffectApplied = filterDescriptor.getBoolean(s2t("blurbGeneralBlurEffectApplied")); //only create variable if field blur is applied
} else {
var blurbGeneralBlurEffectApplied = false;
}
if (filterDescriptor.hasKey(s2t("blurbIrisBlurEffectApplied"))) {
var blurbIrisBlurEffectApplied = filterDescriptor.getBoolean(s2t("blurbIrisBlurEffectApplied")); //only create variable if iris blur is applied
} else {
var blurbIrisBlurEffectApplied = false;
}
var blurbSaveMaskChannel = filterDescriptor.getBoolean(s2t("blurbSaveMaskChannel"));
var blurbHighQuality = filterDescriptor.getBoolean(s2t("blurbHighQuality"));
 
var blurWidgetCount = filterDescriptor.getList(s2t("blurbWidgetList")).count; //number of blurs applied inside blur gallery
 
var blurbWidgetType = [];
var blurbWidgetLocationX = [];
var blurbWidgetLocationY = [];
var blurbWidgetSelected = [];
var blurbWidgetEffectEnabled = [];
 
//unique to field blur
var blurbGeneralBlurAmount = [];
 
//unique to iris blur
var blurbWidgetFade = [];
var blurbIrisBlurAmount= [];
var blurbIrisBlurEccentricity= [];
var blurbIrisBlurFeather0= [];
var blurbIrisBlurFeather1= [];
var blurbIrisBlurFeather2= [];
var blurbIrisBlurFeather3= [];
var blurbIrisBlurCorner0x= [];
var blurbIrisBlurCorner0y= [];
var blurbIrisBlurCorner1x= [];
var blurbIrisBlurCorner1y= [];
var blurbIrisBlurCorner2x= [];
var blurbIrisBlurCorner2y= [];
var blurbIrisBlurCorner3x= [];
var blurbIrisBlurCorner3y= [];

for (j = 0; j < blurWidgetCount; j++) {
blurbWidgetType[j] = blurbWidgetList.getObjectValue(j).getInteger(s2t("blurbWidgetType"));
if (blurbWidgetType[j] == 0) { //field blur
blurbWidgetLocationX[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbWidgetLocationX"));
blurbWidgetLocationY[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbWidgetLocationY"));
blurbWidgetSelected[j] = blurbWidgetList.getObjectValue(j).getBoolean(s2t("blurbWidgetSelected"));
blurbWidgetEffectEnabled[j] = blurbWidgetList.getObjectValue(j).getBoolean(s2t("blurbWidgetEffectEnabled"));
blurbGeneralBlurAmount[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbGeneralBlurAmount"))*scaleFactor;
} else if (blurbWidgetType[j] == 1) { //iris blur
blurbWidgetLocationX[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbWidgetLocationX"));
blurbWidgetLocationY[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbWidgetLocationY"));
blurbWidgetSelected[j] = blurbWidgetList.getObjectValue(j).getBoolean(s2t("blurbWidgetSelected"));
blurbWidgetEffectEnabled[j] = blurbWidgetList.getObjectValue(j).getBoolean(s2t("blurbWidgetEffectEnabled"));
blurbWidgetFade[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbWidgetFade"));
blurbIrisBlurAmount[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurAmount"))*scaleFactor;
blurbIrisBlurEccentricity[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurEccentricity"));
blurbIrisBlurFeather0[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurFeather0"));
blurbIrisBlurFeather1[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurFeather1"));
blurbIrisBlurFeather2[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurFeather2"));
blurbIrisBlurFeather3[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurFeather3"));
blurbIrisBlurCorner0x[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurCorner0x"));
blurbIrisBlurCorner0y[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurCorner0y"));
blurbIrisBlurCorner1x[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurCorner1x"));
blurbIrisBlurCorner1y[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurCorner1y"));
blurbIrisBlurCorner2x[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurCorner2x"));
blurbIrisBlurCorner2y[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurCorner2y"));
blurbIrisBlurCorner3x[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurCorner3x"));
blurbIrisBlurCorner3y[j] = blurbWidgetList.getObjectValue(j).getDouble(s2t("blurbIrisBlurCorner3y"));
}
}

var PuX0 = filterDescriptor.getDouble(s2t("PuX0"));
var PuX1 = filterDescriptor.getDouble(s2t("PuX1"));
var PuX2 = filterDescriptor.getDouble(s2t("PuX2"));
var PuX3 = filterDescriptor.getDouble(s2t("PuX3"));
var PuY0 = filterDescriptor.getDouble(s2t("PuY0"));
var PuY1 = filterDescriptor.getDouble(s2t("PuY1"));
var PuY2 = filterDescriptor.getDouble(s2t("PuY2"));
var PuY3 = filterDescriptor.getDouble(s2t("PuY3"));

var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var descriptor3 = new ActionDescriptor();
var descriptor4 = new ActionDescriptor();
var blurWidgetDescriptorArray = [];
var list = new ActionList();
var reference = new ActionReference();

reference.putIndex( s2t( "filterFX" ), index+1);
reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
descriptor.putReference( s2t( "null" ), reference );
descriptor3.putBoolean( s2t( "blurbType" ), blurbType );
descriptor3.putInteger( s2t( "versionMajor" ), versionMajor );
descriptor3.putInteger( s2t( "versionMinor" ), versionMinor );
descriptor4.putInteger( s2t( "top" ), top );
descriptor4.putInteger( s2t( "left" ), left );
descriptor4.putInteger( s2t( "bottom" ), bottom );
descriptor4.putInteger( s2t( "right" ), right );
descriptor3.putObject( s2t( "referenceRect" ), s2t( "rectangle" ), descriptor4 );
descriptor3.putInteger( s2t( "blurbOpenPanel" ), blurbOpenPanel );

descriptor3.putBoolean( s2t( "blurbGeneralBlurEffectApplied" ), blurbGeneralBlurEffectApplied ); //iris field
descriptor3.putBoolean( s2t( "blurbIrisBlurEffectApplied" ), blurbIrisBlurEffectApplied ); //iris blur
 
descriptor3.putBoolean( s2t( "blurbSaveMaskChannel" ), blurbSaveMaskChannel );
descriptor3.putBoolean( s2t( "blurbHighQuality" ), blurbHighQuality );


for (j = 0; j < blurWidgetCount; j++) {
if (blurbWidgetType[j] == 0) { //field blur
blurWidgetDescriptorArray.push(new ActionDescriptor());
blurWidgetDescriptorArray[j].putInteger( s2t( "blurbWidgetType" ), blurbWidgetType[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbWidgetLocationX" ), blurbWidgetLocationX[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbWidgetLocationY" ), blurbWidgetLocationY[j] );
blurWidgetDescriptorArray[j].putBoolean( s2t( "blurbWidgetSelected" ), blurbWidgetSelected[j] );
blurWidgetDescriptorArray[j].putBoolean( s2t( "blurbWidgetEffectEnabled" ), blurbWidgetEffectEnabled[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbGeneralBlurAmount" ), blurbGeneralBlurAmount[j] );
list.putObject( s2t( "blurbWidget" ), blurWidgetDescriptorArray [j] );
} else if (blurbWidgetType[j] == 1) { //iris blur{
blurWidgetDescriptorArray.push(new ActionDescriptor());
blurWidgetDescriptorArray[j].putInteger( s2t( "blurbWidgetType" ), blurbWidgetType[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbWidgetLocationX" ), blurbWidgetLocationX[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbWidgetLocationY" ), blurbWidgetLocationY[j] );
blurWidgetDescriptorArray[j].putBoolean( s2t( "blurbWidgetSelected" ), blurbWidgetSelected[j] );
blurWidgetDescriptorArray[j].putBoolean( s2t( "blurbWidgetEffectEnabled" ), blurbWidgetEffectEnabled[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbWidgetFade" ), blurbWidgetFade[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurAmount" ), blurbIrisBlurAmount[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurEccentricity" ), blurbIrisBlurEccentricity[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurFeather0" ), blurbIrisBlurFeather0[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurFeather1" ), blurbIrisBlurFeather1[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurFeather2" ), blurbIrisBlurFeather2[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurFeather3" ), blurbIrisBlurFeather3[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurCorner0x" ), blurbIrisBlurCorner0x[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurCorner0y" ), blurbIrisBlurCorner0y[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurCorner1x" ), blurbIrisBlurCorner1x[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurCorner1y" ), blurbIrisBlurCorner1y[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurCorner2x" ), blurbIrisBlurCorner2x[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurCorner2y" ), blurbIrisBlurCorner2y[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurCorner3x" ), blurbIrisBlurCorner3x[j] );
blurWidgetDescriptorArray[j].putDouble( s2t( "blurbIrisBlurCorner3y" ), blurbIrisBlurCorner3y[j] );
list.putObject( s2t( "blurbWidget" ), blurWidgetDescriptorArray [j] );
}
}

descriptor3.putList( s2t( "blurbWidgetList" ), list );
descriptor3.putDouble( s2t( "PuX0" ), PuX0 );
descriptor3.putDouble( s2t( "PuX1" ), PuX1 );
descriptor3.putDouble( s2t( "PuX2" ), PuX2 );
descriptor3.putDouble( s2t( "PuX3" ), PuX3 );
descriptor3.putDouble( s2t( "PuY0" ), PuY0 );
descriptor3.putDouble( s2t( "PuY1" ), PuY1 );
descriptor3.putDouble( s2t( "PuY2" ), PuY2 );
descriptor3.putDouble( s2t( "PuY3" ), PuY3 );
descriptor2.putObject( s2t( "filter" ), s2t( "blurbTransform" ), descriptor3 );
descriptor.putObject( s2t( "filterFX" ), s2t( "filterFX" ), descriptor2 );
executeAction( s2t( "set" ), descriptor, DialogModes.NO );
}

function getDescriptor(className) {
var reference = new ActionReference ();
reference.putEnumerated (s2t (className), s2t ("ordinal"), s2t ("targetEnum"));
var descriptor = executeActionGet(reference);
return descriptor;
}

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 ,
Jul 31, 2022 Jul 31, 2022

Copy link to clipboard

Copied

Thanks! 

 

I had thought that simulating a keystroke might work, alas, the code does not seem to progress unless the dialog is OK-ed. 

Sorry, I fail to see a solution here. 

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 ,
Jul 31, 2022 Jul 31, 2022

Copy link to clipboard

Copied

@Tom Ruark, please forgive the intrusion, but can you shed some light on this situation (Filter Gallery Filters’ behaviour when triggered via Script)? 

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 Beginner ,
Jul 31, 2022 Jul 31, 2022

Copy link to clipboard

Copied

When the script runs it prompts the user for a percentage to scale the blur amount. Then it opens the Blur Gallery dialog and updates the blur amounts. Unfortunately, the dialog stays open and I have to manually hit enter to apply the new settings. If there is more than one blur applied, I have to hit enter multiple times to continue. Any thoughts? Thanks!

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
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

I can repro here. Let me see if the debugger tells me anything that you could use to work around.

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
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

From the actions panel you can see the same issue. If you create a new smart filter with Blur Gallery then all is ok. If you record the edit of one and play that back you get the dialog. We are calling the "interact" code and ignoring the dialog options in "edit" side of the code. The only work around that *may* work would be to remove the smart filter and then re add it as new.

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 ,
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

Thank you for checking! 

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 Beginner ,
Sep 22, 2022 Sep 22, 2022

Copy link to clipboard

Copied

LATEST

Finally, got back to this. Tom, thanks for pointing a way forward! I just had to reverse the order you suggested:  I added the new smart filter and then removed the original. I was able to use:

 

 

executeAction( s2t( "blurbTransform" ), descriptor3, DialogModes.NO );

instead of:

executeAction( s2t( "set" ), descriptor, DialogModes.NO );

 

This line of code stacked a new smart filter with the scaled blur gallery settings at the top of the smart filter list. Once I realized this worked I changed the code to temporarily duplicate each layer filter so there were two "sets" of filters: a complete set of the original layer filters below a complete set of duplicates (with blur gallery filters scaled in the duplicate set). Then I deleted the original layer filter set. This allowed me to scale the blur gallery filters without bringing up the dialog ui and preserve the original layer filter order. Thanks again. Hopefully this information will be useful to someone else in the future.

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