Manipulate Action Manager Code to return Select and Mask Values?
Posted: Fri Jan 26, 2018 6:57 pm
I am trying to create a function to run Select and Mask that will return the values the user enters (slider values, not the manual brushing). I have done a similar thing with user editing a Solid Color layer where it returns the RGB values the user set. Mike Hale helped with that one a few years back.
I have tried a bunch of ways but I just don't understand AM code well enough to pull it off.
Here is the function of Select and MAsk made from script listener.
function selectAndMask(radius,smooth,feather,contrast,shift){
// =======================================================
var idsmartBrushWorkspace = stringIDToTypeID( "smartBrushWorkspace" );
var desc18 = new ActionDescriptor();
var idsmartBrushRadius = stringIDToTypeID( "smartBrushRadius" );
desc18.putInteger( idsmartBrushRadius, radius );
var idsmartBrushSmooth = stringIDToTypeID( "smartBrushSmooth" );
desc18.putInteger( idsmartBrushSmooth, smooth );
var idsmartBrushFeather = stringIDToTypeID( "smartBrushFeather" );
var idPxl = charIDToTypeID( "#Pxl" );
desc18.putUnitDouble( idsmartBrushFeather, idPxl, feather );
var idsmartBrushContrast = stringIDToTypeID( "smartBrushContrast" );
var idPrc = charIDToTypeID( "#Prc" );
desc18.putUnitDouble( idsmartBrushContrast, idPrc, contrast );
var idsmartBrushShiftEdge = stringIDToTypeID( "smartBrushShiftEdge" );
var idPrc = charIDToTypeID( "#Prc" );
desc18.putUnitDouble( idsmartBrushShiftEdge, idPrc, shift );
var idsampleAllLayers = stringIDToTypeID( "sampleAllLayers" );
desc18.putBoolean( idsampleAllLayers, false );
var idsmartBrushUseSmartRadius = stringIDToTypeID( "smartBrushUseSmartRadius" );
desc18.putBoolean( idsmartBrushUseSmartRadius, false );
var idsmartBrushDecontaminate = stringIDToTypeID( "smartBrushDecontaminate" );
desc18.putBoolean( idsmartBrushDecontaminate, false );
var idsmartBrushDeconAmount = stringIDToTypeID( "smartBrushDeconAmount" );
var idPrc = charIDToTypeID( "#Prc" );
desc18.putUnitDouble( idsmartBrushDeconAmount, idPrc, 100.000000 );
var idrefineEdgeOutput = stringIDToTypeID( "refineEdgeOutput" );
var idrefineEdgeOutput = stringIDToTypeID( "refineEdgeOutput" );
var idselectionOutputToUserMask = stringIDToTypeID( "selectionOutputToUserMask" );
desc18.putEnumerated( idrefineEdgeOutput, idrefineEdgeOutput, idselectionOutputToUserMask );
executeAction( idsmartBrushWorkspace, desc18, DialogModes.ALL );
}
Here is code for updating values for a solid color layer where it returns the RGB values when the user changes them. I am wanting to use this method to return the 5 slider values from the Select an Mask function and possibly the true/false for the smart radius brush as well.
var desc = editSolidColor(128,128,128);
ToDesc=desc.getObjectValue(charIDToTypeID( "T " ));
list=ToDesc.getList(charIDToTypeID( "Clr " ));
levelDesc=list.getObjectValue(0);
var redValue=Math.round(levelDesc.getDouble(charIDToTypeID( "Rd " )));
var greenValue=Math.round(levelDesc.getDouble(charIDToTypeID( "Grn " )));
var blueValue=Math.round(levelDesc.getDouble(charIDToTypeID( "Bl " )));
alert(redValue+','+greenValue+','+blueValue);
function editSolidColor(red,green,blue){
var id30 = charIDToTypeID( "setd" );
var desc7 = new ActionDescriptor();
var id31 = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var id32 = stringIDToTypeID( "contentLayer" );
var id33 = charIDToTypeID( "Ordn" );
var id34 = charIDToTypeID( "Trgt" );
ref2.putEnumerated( id32, id33, id34 );
desc7.putReference( id31, ref2 );
var id35 = charIDToTypeID( "T " );
var desc8 = new ActionDescriptor();
var id36 = charIDToTypeID( "Clr " );
var desc9 = new ActionDescriptor();
var id37 = charIDToTypeID( "Rd " );
desc9.putDouble( id37, red );
var id38 = charIDToTypeID( "Grn " );
desc9.putDouble( id38, green );
var id39 = charIDToTypeID( "Bl " );
desc9.putDouble( id39, blue );
var id40 = charIDToTypeID( "RGBC" );
desc8.putObject( id36, id40, desc9 );
var id41 = stringIDToTypeID( "solidColorLayer" );
desc7.putObject( id35, id41, desc8 );
return userRGB = executeAction( id30, desc7, DialogModes.ALL );
}
I have tried a bunch of ways but I just don't understand AM code well enough to pull it off.
Here is the function of Select and MAsk made from script listener.
function selectAndMask(radius,smooth,feather,contrast,shift){
// =======================================================
var idsmartBrushWorkspace = stringIDToTypeID( "smartBrushWorkspace" );
var desc18 = new ActionDescriptor();
var idsmartBrushRadius = stringIDToTypeID( "smartBrushRadius" );
desc18.putInteger( idsmartBrushRadius, radius );
var idsmartBrushSmooth = stringIDToTypeID( "smartBrushSmooth" );
desc18.putInteger( idsmartBrushSmooth, smooth );
var idsmartBrushFeather = stringIDToTypeID( "smartBrushFeather" );
var idPxl = charIDToTypeID( "#Pxl" );
desc18.putUnitDouble( idsmartBrushFeather, idPxl, feather );
var idsmartBrushContrast = stringIDToTypeID( "smartBrushContrast" );
var idPrc = charIDToTypeID( "#Prc" );
desc18.putUnitDouble( idsmartBrushContrast, idPrc, contrast );
var idsmartBrushShiftEdge = stringIDToTypeID( "smartBrushShiftEdge" );
var idPrc = charIDToTypeID( "#Prc" );
desc18.putUnitDouble( idsmartBrushShiftEdge, idPrc, shift );
var idsampleAllLayers = stringIDToTypeID( "sampleAllLayers" );
desc18.putBoolean( idsampleAllLayers, false );
var idsmartBrushUseSmartRadius = stringIDToTypeID( "smartBrushUseSmartRadius" );
desc18.putBoolean( idsmartBrushUseSmartRadius, false );
var idsmartBrushDecontaminate = stringIDToTypeID( "smartBrushDecontaminate" );
desc18.putBoolean( idsmartBrushDecontaminate, false );
var idsmartBrushDeconAmount = stringIDToTypeID( "smartBrushDeconAmount" );
var idPrc = charIDToTypeID( "#Prc" );
desc18.putUnitDouble( idsmartBrushDeconAmount, idPrc, 100.000000 );
var idrefineEdgeOutput = stringIDToTypeID( "refineEdgeOutput" );
var idrefineEdgeOutput = stringIDToTypeID( "refineEdgeOutput" );
var idselectionOutputToUserMask = stringIDToTypeID( "selectionOutputToUserMask" );
desc18.putEnumerated( idrefineEdgeOutput, idrefineEdgeOutput, idselectionOutputToUserMask );
executeAction( idsmartBrushWorkspace, desc18, DialogModes.ALL );
}
Here is code for updating values for a solid color layer where it returns the RGB values when the user changes them. I am wanting to use this method to return the 5 slider values from the Select an Mask function and possibly the true/false for the smart radius brush as well.
var desc = editSolidColor(128,128,128);
ToDesc=desc.getObjectValue(charIDToTypeID( "T " ));
list=ToDesc.getList(charIDToTypeID( "Clr " ));
levelDesc=list.getObjectValue(0);
var redValue=Math.round(levelDesc.getDouble(charIDToTypeID( "Rd " )));
var greenValue=Math.round(levelDesc.getDouble(charIDToTypeID( "Grn " )));
var blueValue=Math.round(levelDesc.getDouble(charIDToTypeID( "Bl " )));
alert(redValue+','+greenValue+','+blueValue);
function editSolidColor(red,green,blue){
var id30 = charIDToTypeID( "setd" );
var desc7 = new ActionDescriptor();
var id31 = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var id32 = stringIDToTypeID( "contentLayer" );
var id33 = charIDToTypeID( "Ordn" );
var id34 = charIDToTypeID( "Trgt" );
ref2.putEnumerated( id32, id33, id34 );
desc7.putReference( id31, ref2 );
var id35 = charIDToTypeID( "T " );
var desc8 = new ActionDescriptor();
var id36 = charIDToTypeID( "Clr " );
var desc9 = new ActionDescriptor();
var id37 = charIDToTypeID( "Rd " );
desc9.putDouble( id37, red );
var id38 = charIDToTypeID( "Grn " );
desc9.putDouble( id38, green );
var id39 = charIDToTypeID( "Bl " );
desc9.putDouble( id39, blue );
var id40 = charIDToTypeID( "RGBC" );
desc8.putObject( id36, id40, desc9 );
var id41 = stringIDToTypeID( "solidColorLayer" );
desc7.putObject( id35, id41, desc8 );
return userRGB = executeAction( id30, desc7, DialogModes.ALL );
}