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;
}