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

Fix "the command get is not currently available" in CS6

Engaged ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

I want use Photoshop CS6 for batch editing because it is lite and can be used in sandboxie software

following script is fully execute in the latest version of Photoshop (2023): 

 

 

#target photoshop

/* Check for selection - from jazz-y */
var selectionBounds = null;
try {
    selectionBounds = activeDocument.selection.bounds
} catch (e) {}
if (selectionBounds) {

        /* Start Process selected layers - from jazz-y */
        var s2t = stringIDToTypeID;
        (r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
        r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
        var lrs = executeActionGet(r).getList(p),
            sel = new ActionReference();
        for (var i = 0; i < lrs.count; i++) {
            sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
            (r = new ActionReference()).putIdentifier(s2t('layer'), p);
            (d = new ActionDescriptor()).putReference(s2t("target"), r);
            executeAction(s2t('select'), d, DialogModes.NO);
        /* End Process selected layers - from jazz-y */

        /* Clear selected layers */
        try {
            activeDocument.selection.clear()
        } catch (e) {}
    }

} else {
    alert("This script requires a selection!");
}

 

 

but when i run above script in CS6 i get following error: 

 

Untitle345345345345d.jpg 

 

how to fix this error in CS6? 

TOPICS
Actions and scripting

Views

619

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

People's Champ , Jul 12, 2023 Jul 12, 2023
var nn = 0;
try { activeDocument.backgroundLayer } catch(e) { nn = 1; }

var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayers'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p),
    sel = new ActionReference();

for (var i = 0; i < lrs.count; i++) {
    sel.putIndex(s2t('layer'), p = lrs.getReference(i).getIndex(i));
    (r = new ActionReference()).putIndex(s2t('layer'), p+nn);
  
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

I can’t remember in which version the selected layers finally became addressable in a meaningful manner, but prior to that there used to be work-arounds using DOM-code. 

This example provides an Array of ArtLayers – in DOM, not AM!

So you would need to adapt the whole for-clause 

        for (var i = 0; i < lrs.count; i++) {

accordingly. 

 

This example might give you a start: 

#target photoshop
var myDocument = app.activeDocument;
alert (getSelectedArtLayers(myDocument))


////// adapted from an xbytor script, thanks to xbytor //////
function getSelectedArtLayers (doc) {
	var layerSets = collectLayerSets(doc);
	var visibleSets = [];
	for (var m = 0; m < layerSets.length; m++) {
		var theSet = layerSets[m];
		visibleSets[m] = theSet.visible;
		theSet.visible = true;
		};	
	var layers = collectArtLayers(doc);
	var visible = [];
	var selLayers = [];
	for (var i = 0; i < layers.length; i++) {
		var l = layers[i];
		visible[i] = l.visible;
		l.visible = true;
		};
////// hide selected;
	var id807 = charIDToTypeID( "Hd  " );
	var desc161 = new ActionDescriptor();
	var id808 = charIDToTypeID( "null" );
	var ref116 = new ActionReference();
	var id809 = charIDToTypeID( "Lyr " );
	var id810 = charIDToTypeID( "Ordn" );
	var id811 = charIDToTypeID( "Trgt" );
	ref116.putEnumerated( id809, id810, id811 );
	desc161.putReference( id808, ref116 );
	executeAction( id807, desc161, DialogModes.NO );
// show all layersets;
	for (var m = 0; m < layerSets.length; m++) {
		var theSet = layerSets[m];
		theSet.visible = true;
		};
//////
	for (var i = 0; i < layers.length; i++) {
		var l = layers[i];
		if (!l.visible) {
			selLayers.push(l);			
			};
		l.visible = visible[i];
		};
// reset layerset visibility;
	for (var m = 0; m < layerSets.length; m++) {
		var theSet = layerSets[m];
		theSet.visible = visibleSets[m];
		};
	return selLayers;
	};

 

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
Engaged ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

quote

I

By @c.pfaffenbichler

tnq, if it possible plz re-write my script for working by CS6

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 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

It seems you want to use Photposhop Scripts for highly specific tasks and, in this case, in a highly specific set-up (on obsolete software). 

I think it is time for you to familiarize yourself with Photoshop Scripting so you don’t need to rely on others to create or adapt them for you. 

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
Engaged ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

quote

It seems you want to use Photposhop Scripts for highly specific tasks and, in this case, in a highly specific set-up (on obsolete software). 

I think it is time for you to familiarize yourself with Photoshop Scripting so you don’t need to rely on others to create or adapt them for you. 


By @c.pfaffenbichler

Thank you, but I have all the scripts needed to edit chart images. The problem is that some scripts do not work with CS6. If I solve the scripts problems, my work will be completed. i can batch editing my images with latest version of photoshop but it take 2 hour time to complete and i have to use CS6 with sandboxie software.

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
Engaged ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

I checked and found that only scripts that use following code not working with CS6 and other scripts working! 

#target photoshop

/* Start Process selected layers - from jazz-y */
var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p),
    sel = new ActionReference();

for (var i = 0; i < lrs.count; i++) {
    sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
    (r = new ActionReference()).putIdentifier(s2t('layer'), p);
    (d = new ActionDescriptor()).putReference(s2t("target"), r);
    executeAction(s2t('select'), d, DialogModes.NO);
/* End Process selected layers - from jazz-y */

// Your code here:
alert(activeDocument.activeLayer.name);

}

 

 

 

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 ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

var nn = 0;
try { activeDocument.backgroundLayer } catch(e) { nn = 1; }

var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayers'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p),
    sel = new ActionReference();

for (var i = 0; i < lrs.count; i++) {
    sel.putIndex(s2t('layer'), p = lrs.getReference(i).getIndex(i));
    (r = new ActionReference()).putIndex(s2t('layer'), p+nn);
    (d = new ActionDescriptor()).putReference(s2t("target"), r);
    executeAction(s2t('select'), d, DialogModes.NO);

// Your code here:
alert(activeDocument.activeLayer.name);

}

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
Engaged ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

LATEST
quote

 

var nn = 0;
try { activeDocument.backgroundLayer } catch(e) { nn = 1; }

var s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('targetLayers'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p),
    sel = new ActionReference();

for (var i = 0; i < lrs.count; i++) {
    sel.putIndex(s2t('layer'), p = lrs.getReference(i).getIndex(i));
    (r = new ActionReference()).putIndex(s2t('layer'), p+nn);
    (d = new ActionDescriptor()).putReference(s2t("target"), r);
    executeAction(s2t('select'), d, DialogModes.NO);

// Your code here:
alert(activeDocument.activeLayer.name);

}


By @r-bin

 

TNQ very much it solved problem

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
Engaged ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

@Stephen Marsh 

can you fix script error for cs6?

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