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

Get the number of active selections

Engaged ,
Jun 05, 2021 Jun 05, 2021

Copy link to clipboard

Copied

A photoshop document has multiple active selections on the canvas.

A square selection, around selection, and irregular selection for example.

Is it possible to alert the number of active selections at a given time?

 

 

TOPICS
Actions and scripting

Views

3.6K

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

correct answers 1 Correct answer

LEGEND , Jun 05, 2021 Jun 05, 2021
function slctns() {
	return sTT = stringIDToTypeID,
	aHS = (aD = activeDocument).activeHistoryState,
	(ref1 = new ActionReference()).putClass(sTT('path')),
	(dsc = new ActionDescriptor()).putReference(sTT('null'), ref1),
	(ref2 = new ActionReference()).putProperty(sTT('selectionClass'), sTT('selection')),
	dsc.putReference(sTT('from'), ref2), dsc.putUnitDouble(sTT('tolerance'), sTT('pixelsUnit'), .5),
	executeAction(sTT('make'), dsc), lngth = aD.pathItems[0].subPathItems.length, aD.activeHistory
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 06, 2021 Jun 06, 2021

Copy link to clipboard

Copied

We knew what your were after.  I was just pointing out that your concept that Photoshop has multiple Active selection is not correct.  What the code does is have Photoshop map the active selection that is create a path like contour line on a map the Path will have Path items  that map each of the layer selected pixel areas.  A selection is a  singular thing its a map.   You can have many saved selections  there is only one active selection you have it or to don't and can be changed/modified.

JJMack

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
LEGEND ,
Jun 06, 2021 Jun 06, 2021

Copy link to clipboard

Copied

LATEST

From last few requests I learnt users can't describe what they want, so they often mislead unintentionally. Knowing that I try to guess what the logic is covered below their "image".

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
People's Champ ,
Jun 05, 2021 Jun 05, 2021

Copy link to clipboard

Copied

var file = new File(Folder.temp.fsName + "/" + "tmp");

var d = new ActionDescriptor();
executeAction(stringIDToTypeID("deleteMeasurements"), d, DialogModes.NO);

var d = new ActionDescriptor();
d.putEnumerated(stringIDToTypeID("source"), stringIDToTypeID("measurementSource"), stringIDToTypeID("selection"));
var list = new ActionList();
list.putEnumerated(stringIDToTypeID("measurementDataPoint"), stringIDToTypeID("Count"));
d.putList(stringIDToTypeID("dataPoints"), list);
var d = executeAction(stringIDToTypeID("recordMeasurements"), d, DialogModes.NO);

var d = new ActionDescriptor();
d.putPath(stringIDToTypeID("file"), file);
executeAction(stringIDToTypeID("exportMeasurements"), d, DialogModes.NO);

var d = new ActionDescriptor();
executeAction(stringIDToTypeID("deleteMeasurements"), d, DialogModes.NO);

file.open("r");

var s = file.read();

file.close();
file.remove();

alert(s);

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