Skip to main content
Participant
January 6, 2019
Answered

The command “Transform” is not currently available.

  • January 6, 2019
  • 3 replies
  • 4726 views

I am using JavaScript to script Photoshop.

I am trying to resize an art layer that has text in it. When calling the resize method on the art layer, I get the error:

The command “Transform” is not currently available.

However, if i select the layer manually before running the script, I get no such error.
How can I bypass this error or how can I automatically select the layer to where the program functions properly? Why doesn't transform functions like the resize method just work without manually selecting the layer beforehand?

This topic has been closed for replies.
Correct answer pixxxelschubser

or simple by name (eg "Ziel")

(ref1 = new ActionReference()).putName(stringIDToTypeID('layer'), "Ziel" );

(desc1 = new ActionDescriptor()).putReference(stringIDToTypeID('null'), ref1)

desc1.putBoolean(stringIDToTypeID('makeVisible'), false);

executeAction(stringIDToTypeID('select'), desc1, DialogModes.NO);

Have fun

3 replies

Kukurykus
Legend
January 6, 2019

You may use this code when no layers are selected, where 'selectNoLayers' must be used when some is actually selected:

sTT = stringIDToTypeID, $.level = 0; try{runMenuItem(sTT('selectNoLayers'))}catch(err){}

(ref = new ActionReference()).putEnumerated(sTT('layer'), sTT('ordinal'), sTT('backwardEnum'));

(dsc = new ActionDescriptor()).putReference(sTT('null'), ref), executeAction(sTT('select'), dsc)

or simply this one:

sTT = stringIDToTypeID

ref = new ActionReference(), dsc = new ActionDescriptor()

ref.putEnumerated(sTT('layer'), sTT('ordinal'), sTT('front'))

dsc.putReference(sTT('null'), ref), executeAction(sTT('select'), dsc)

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
January 6, 2019

or simple by name (eg "Ziel")

(ref1 = new ActionReference()).putName(stringIDToTypeID('layer'), "Ziel" );

(desc1 = new ActionDescriptor()).putReference(stringIDToTypeID('null'), ref1)

desc1.putBoolean(stringIDToTypeID('makeVisible'), false);

executeAction(stringIDToTypeID('select'), desc1, DialogModes.NO);

Have fun

pixxxelschubser
Community Expert
Community Expert
January 6, 2019

This error occurs if no layer is selected.

You can use AM-code or a simple workaround. Try this (if your layer really is the topmost layer)

var aDoc = activeDocument;

var aLay = aDoc.layers[0];

var tempLay = aDoc.artLayers.add();

tempLay.remove();

aLay.resize(150, 150);

Have fun

Chuck Uebele
Community Expert
Community Expert
January 6, 2019

Can you share your code to see what you're doing?

you can either just change the font size, best option, or use this code:

var doc = activeDocument

var aLay = doc.activeLayer

aLay.resize(200,200, AnchorPosition.MIDDLECENTER)//replace the 200 with whatever percentage you want the layer to increase.

Participant
January 6, 2019

var docRef = app.activeDocument

var firstLayer = docRef.artLayers[0]

docRef.activeLayer = firstLayer

firstLayer.resize(150, 150)

Chuck Uebele
Community Expert
Community Expert
January 6, 2019

Can you also show a screen shot of your file and the layers in the file?