Skip to main content
jidenshaotoko
Participating Frequently
Mar 20, 2025 3:47 AM UTC
Answered

I'm looking for a script to toggle anti-alias on the Polygonal Lasso Tool

I have a script I got from somewhere I don't remember that lets me toggle the sample mode on the eyedropper tool with just one keyboard shortcut, regardless of whether the tool is active or not.

 

Is it possible to do the same but with the anti-alias on the polygonal lasso tool, with no confirmation dialog being shown afterwards?

c.pfaffenbichler
c.pfaffenbichlerCorrect answer
Community Expert
Mar 20, 2025 3:22 PM UTC

This would work with the tool selected. 

// thanks to Oleksii Hirlin;
// switch anti-alias-setting for polygonal lasso tool;
// 2025, use it at your own risk;
if (getCurrentTool() == "polySelTool") {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID('property'), stringIDToTypeID("currentToolOptions"));
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var applicationDesc = executeActionGet(ref);
var currentToolS = applicationDesc.getObjectValue(stringIDToTypeID("currentToolOptions"));
// get setting;
var theAntiAlias = currentToolS.getBoolean(1148352321);
// set;
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( stringIDToTypeID( app.currentTool ) );
desc.putReference( stringIDToTypeID( "target" ), ref );
if (theAntiAlias == true) {
currentToolS.putBoolean(1148352321, false)
} else {
currentToolS.putBoolean(1148352321, true)
};
desc.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "currentToolOptions" ), currentToolS );
executeAction( stringIDToTypeID( "set" ), desc, DialogModes.NO );
};
////////////////////////////////////
function getCurrentTool() {
var ref = new ActionReference(); 
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
return typeIDToStringID(executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool')));
};

2 replies

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
Mar 20, 2025 3:22 PM UTC

This would work with the tool selected. 

// thanks to Oleksii Hirlin;
// switch anti-alias-setting for polygonal lasso tool;
// 2025, use it at your own risk;
if (getCurrentTool() == "polySelTool") {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID('property'), stringIDToTypeID("currentToolOptions"));
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var applicationDesc = executeActionGet(ref);
var currentToolS = applicationDesc.getObjectValue(stringIDToTypeID("currentToolOptions"));
// get setting;
var theAntiAlias = currentToolS.getBoolean(1148352321);
// set;
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( stringIDToTypeID( app.currentTool ) );
desc.putReference( stringIDToTypeID( "target" ), ref );
if (theAntiAlias == true) {
currentToolS.putBoolean(1148352321, false)
} else {
currentToolS.putBoolean(1148352321, true)
};
desc.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "currentToolOptions" ), currentToolS );
executeAction( stringIDToTypeID( "set" ), desc, DialogModes.NO );
};
////////////////////////////////////
function getCurrentTool() {
var ref = new ActionReference(); 
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
return typeIDToStringID(executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool')));
};
Translate
jidenshaotoko
Participating Frequently
Mar 27, 2025 1:26 PM UTC

Worked like a charm. Thank you very much!

Translate