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

Script Listener code will not execute...

Engaged ,
Jun 12, 2015 Jun 12, 2015

Copy link to clipboard

Copied

The code below was generated by the Script Listener in PS CC 2014 with all updates. When I run the code in Extend Script an exception is thrown by the last line stating that the Make command is not available in this version of PS! How can I fix this? Thanks.

By the way, how can I paste code into a message here and preserve the indenting. Sometimes the indents are preserved and sometimes not.

function createInnerGlowRectangle(recTop, recLeft, recBottom, recRight, recResolution) {

  // Draws a rectangle using the Rectangle tool.

  // =======================================================

  var idMk = charIDToTypeID( "Mk  " );

  var desc2 = new ActionDescriptor();

  var idnull = charIDToTypeID( "null" );

  var ref1 = new ActionReference();

  var idcontentLayer = stringIDToTypeID( "contentLayer" );

  ref1.putClass( idcontentLayer );

  desc2.putReference( idnull, ref1 );

  var idUsng = charIDToTypeID( "Usng" );

  var desc3 = new ActionDescriptor();

  var idType = charIDToTypeID( "Type" );

  var desc4 = new ActionDescriptor();

  var idClr = charIDToTypeID( "Clr " );

  var desc5 = new ActionDescriptor();

  var idRd = charIDToTypeID( "Rd  " );

  desc5.putDouble( idRd, 255.000000 );

  var idGrn = charIDToTypeID( "Grn " );

  desc5.putDouble( idGrn, 255.000000 );

  var idBl = charIDToTypeID( "Bl  " );

  desc5.putDouble( idBl, 255.000000 );

  var idRGBC = charIDToTypeID( "RGBC" );

  desc4.putObject( idClr, idRGBC, desc5 );

  var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

  desc3.putObject( idType, idsolidColorLayer, desc4 );

  var idShp = charIDToTypeID( "Shp " );

  var desc6 = new ActionDescriptor();

  var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" );

  desc6.putInteger( idunitValueQuadVersion, 1 );

  var idTop = charIDToTypeID( "Top " );

  var idPxl = charIDToTypeID( "#Pxl" );

  desc6.putUnitDouble( idTop, idPxl, recTop );

  var idLeft = charIDToTypeID( "Left" );

  var idPxl = charIDToTypeID( "#Pxl" );

  desc6.putUnitDouble( idLeft, idPxl, recLeft );

  var idBtom = charIDToTypeID( "Btom" );

  var idPxl = charIDToTypeID( "#Pxl" );

  desc6.putUnitDouble( idBtom, idPxl, recBottom );

  var idRght = charIDToTypeID( "Rght" );

  var idPxl = charIDToTypeID( "#Pxl" );

  desc6.putUnitDouble( idRght, idPxl, recRight );

  var idtopRight = stringIDToTypeID( "topRight" );

  var idPxl = charIDToTypeID( "#Pxl" );

  desc6.putUnitDouble( idtopRight, idPxl, -1.000000 );

  var idtopLeft = stringIDToTypeID( "topLeft" );

  var idPxl = charIDToTypeID( "#Pxl" );

  desc6.putUnitDouble( idtopLeft, idPxl, -1.000000 );

  var idbottomLeft = stringIDToTypeID( "bottomLeft" );

  var idPxl = charIDToTypeID( "#Pxl" );

  desc6.putUnitDouble( idbottomLeft, idPxl, -1.000000 );

  var idbottomRight = stringIDToTypeID( "bottomRight" );

  var idPxl = charIDToTypeID( "#Pxl" );

  desc6.putUnitDouble( idbottomRight, idPxl, -1.000000 );

  var idRctn = charIDToTypeID( "Rctn" );

  desc3.putObject( idShp, idRctn, desc6 );

  var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

  var desc7 = new ActionDescriptor();

  var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

  desc7.putInteger( idstrokeStyleVersion, 2 );

  var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

  desc7.putBoolean( idstrokeEnabled, false );

  var idfillEnabled = stringIDToTypeID( "fillEnabled" );

  desc7.putBoolean( idfillEnabled, true );

  var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );

  var idPnt = charIDToTypeID( "#Pnt" );

  desc7.putUnitDouble( idstrokeStyleLineWidth, idPnt, 3.000000 );

  var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );

  var idPnt = charIDToTypeID( "#Pnt" );

  desc7.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );

  var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );

  desc7.putDouble( idstrokeStyleMiterLimit, 100.000000 );

  var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

  var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

  var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );

  desc7.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );

  var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

  var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

  var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );

  desc7.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );

  var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

  var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

  var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignInside" );

  desc7.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );

  var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );

  desc7.putBoolean( idstrokeStyleScaleLock, false );

  var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );

  desc7.putBoolean( idstrokeStyleStrokeAdjust, false );

  var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

  var list1 = new ActionList();

  desc7.putList( idstrokeStyleLineDashSet, list1 );

  var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );

  var idBlnM = charIDToTypeID( "BlnM" );

  var idNrml = charIDToTypeID( "Nrml" );

  desc7.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );

  var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );

  var idPrc = charIDToTypeID( "#Prc" );

  desc7.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );

  var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );

  var desc8 = new ActionDescriptor();

  var idClr = charIDToTypeID( "Clr " );

  var desc9 = new ActionDescriptor();

  var idRd = charIDToTypeID( "Rd  " );

  desc9.putDouble( idRd, 0.000000 );

  var idGrn = charIDToTypeID( "Grn " );

  desc9.putDouble( idGrn, 0.000000 );

  var idBl = charIDToTypeID( "Bl  " );

  desc9.putDouble( idBl, 0.000000 );

  var idRGBC = charIDToTypeID( "RGBC" );

  desc8.putObject( idClr, idRGBC, desc9 );

  var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

  desc7.putObject( idstrokeStyleContent, idsolidColorLayer, desc8 );

  var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );

  desc7.putDouble( idstrokeStyleResolution, recResolution );

  var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

  desc3.putObject( idstrokeStyle, idstrokeStyle, desc7 );

  var idcontentLayer = stringIDToTypeID( "contentLayer" );

  desc2.putObject( idUsng, idcontentLayer, desc3 );

  executeAction( idMk, desc2, DialogModes.NO );

TOPICS
Actions and scripting

Views

889

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

Engaged , Jun 12, 2015 Jun 12, 2015

Works for me too on 2014.

Are you sure it is not selected a channel when you run it?

Votes

Translate

Translate
Adobe
Enthusiast ,
Jun 12, 2015 Jun 12, 2015

Copy link to clipboard

Copied

To paste code click the >> and select Syntack Highlighting, then make your selection. I normally choose Plain.

I have tidied your function and it now works for me on CS6.

#target photoshop;

app.bringToFront();

if(documents.length){

var Colour = new SolidColor();

Colour.rgb.hexValue='ff0000'; //red fill

Rectangle(100,10,300,300,300,Colour);

}

function Rectangle(recLeft,recTop,recRight,recBottom,recResolution,Colour) {

var desc2 = new ActionDescriptor();

var ref1 = new ActionReference();

ref1.putClass( stringIDToTypeID('contentLayer') );

desc2.putReference( charIDToTypeID('null'), ref1 );

var desc3 = new ActionDescriptor();

var desc4 = new ActionDescriptor();

var desc5 = new ActionDescriptor();

desc5.putDouble( charIDToTypeID('Rd  '), Colour.rgb.red );

desc5.putDouble( charIDToTypeID('Grn '), Colour.rgb.green );

desc5.putDouble( charIDToTypeID('Bl  '), Colour.rgb.blue );

desc4.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), desc5 );

desc3.putObject( charIDToTypeID('Type'), stringIDToTypeID('solidColorLayer'), desc4 );

var desc6 = new ActionDescriptor();

desc6.putInteger( stringIDToTypeID('unitValueQuadVersion'), 1 );

desc6.putUnitDouble( charIDToTypeID('Top '), charIDToTypeID('#Pxl'), recTop );

desc6.putUnitDouble( charIDToTypeID('Left'), charIDToTypeID('#Pxl'), recLeft );

desc6.putUnitDouble( charIDToTypeID('Btom'), charIDToTypeID('#Pxl'), recBottom );

desc6.putUnitDouble( charIDToTypeID('Rght'), charIDToTypeID('#Pxl'), recRight );

desc6.putUnitDouble( stringIDToTypeID('topRight'), charIDToTypeID('#Pxl'), -1.000000 );

desc6.putUnitDouble( stringIDToTypeID('topLeft'), charIDToTypeID('#Pxl'), -1.000000 );

desc6.putUnitDouble( stringIDToTypeID('bottomLeft'), charIDToTypeID('#Pxl'), -1.000000 );

desc6.putUnitDouble( stringIDToTypeID('bottomRight'), charIDToTypeID('#Pxl'), -1.000000 );

desc3.putObject( charIDToTypeID('Shp '), charIDToTypeID('Rctn'), desc6 );

var desc7 = new ActionDescriptor();

desc7.putInteger( stringIDToTypeID('strokeStyleVersion'), 2 );

desc7.putBoolean( stringIDToTypeID('strokeEnabled'), false );

desc7.putBoolean( stringIDToTypeID('fillEnabled'), true );

desc7.putUnitDouble( stringIDToTypeID('strokeStyleLineWidth'), charIDToTypeID('#Pnt'), 3.000000 );

desc7.putUnitDouble( stringIDToTypeID('strokeStyleLineDashOffset'), charIDToTypeID('#Pnt'), 0.000000 );

desc7.putDouble( stringIDToTypeID('strokeStyleMiterLimit'), 100.000000 );

desc7.putEnumerated( stringIDToTypeID('strokeStyleLineCapType'), stringIDToTypeID('strokeStyleLineCapType'), stringIDToTypeID('strokeStyleButtCap') );

desc7.putEnumerated( stringIDToTypeID('strokeStyleLineJoinType'), stringIDToTypeID('strokeStyleLineJoinType'), stringIDToTypeID('strokeStyleMiterJoin') );

desc7.putEnumerated( stringIDToTypeID('strokeStyleLineAlignment'), stringIDToTypeID('strokeStyleLineAlignment'), stringIDToTypeID('strokeStyleAlignInside') );

desc7.putBoolean( stringIDToTypeID('strokeStyleScaleLock'), false );

desc7.putBoolean( stringIDToTypeID('strokeStyleStrokeAdjust'), false );

var list1 = new ActionList();

desc7.putList( stringIDToTypeID('strokeStyleLineDashSet'), list1 );

desc7.putEnumerated( stringIDToTypeID('strokeStyleBlendMode'), charIDToTypeID('BlnM'), charIDToTypeID('Nrml') );

desc7.putUnitDouble( stringIDToTypeID('strokeStyleOpacity'), charIDToTypeID('#Prc'), 100.000000 );

var desc8 = new ActionDescriptor();

var desc9 = new ActionDescriptor();

desc9.putDouble( charIDToTypeID('Rd  '), 0.000000 );

desc9.putDouble( charIDToTypeID('Grn '), 0.000000 );

desc9.putDouble( charIDToTypeID('Bl  '), 0.000000 );

desc8.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), desc9 );

desc7.putObject( stringIDToTypeID('strokeStyleContent'), stringIDToTypeID('solidColorLayer'), desc8 );

desc7.putDouble( stringIDToTypeID('strokeStyleResolution'), recResolution );

desc3.putObject( stringIDToTypeID('strokeStyle'), stringIDToTypeID('strokeStyle'), desc7 );

desc2.putObject( charIDToTypeID('Usng'), stringIDToTypeID('contentLayer'), desc3 );

executeAction( charIDToTypeID('Mk  '), desc2, DialogModes.NO );

};

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 ,
Jun 12, 2015 Jun 12, 2015

Copy link to clipboard

Copied

Thanks for your efforts. Unfortunately I still get "The command "Make" is not currently available." on the call to executeAction in CC 2014.I think I need to create a simple test script to make sure that the error is not caused by the state PS is in when I call the function in my main script.

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 ,
Jun 12, 2015 Jun 12, 2015

Copy link to clipboard

Copied

Works for me on 2014.

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 ,
Jun 12, 2015 Jun 12, 2015

Copy link to clipboard

Copied

Works for me too on 2014.

Are you sure it is not selected a channel when you run it?

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 ,
Jun 12, 2015 Jun 12, 2015

Copy link to clipboard

Copied

You are right. A channel is selected. I save a selection to a channel and attempt to make the layer active using the following two functions. However the layer is not active in the UI after the call to makeLayerActiveByName(). What do I need to do to select the layer?

Note that the image has been flattened so the only layer is the Background layer. I have stepped through the code in the debugger and the layerName parameter is set to Background.

function makeLayerActiveByName(layerName) {

  activeDocument.activeLayer = activeDocument.artLayers.getByName(layerName);

  activeDocument.activeLayer.selected = true;

}

function saveSelectionToChannel(channelName) {

  // Creates a new channel named channelName and saves the current

  // selection to that channel.

  var savedLayerName = activeDocument.activeLayer.name;

  var chanRef = activeDocument.channels.add();

  chanRef.name = channelName;

  chanRef.kind = ChannelType.SELECTEDAREA;

  activeDocument.selection.store( activeDocument.channels.getByName(channelName));

  makeLayerActiveByName (savedLayerName);

}

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 ,
Jun 12, 2015 Jun 12, 2015

Copy link to clipboard

Copied

The solution to my problem is to make the RGB channel active again after saving the selection to a channel. I tried the following code which does nothing. It does not make the RGB channels active and it does not throw an exception.

activeDocument.activeChannels = [

  activeDocument.channels.getByName("RGB"),

  activeDocument.channels.getByName("Red"),

  activeDocument.channels.getByName("Green"),

  activeDocument.channels.getByName("Blue") ];

Script Listener code does select the RGB channels so I am using that. Thanks for all your help everyone.

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
Enthusiast ,
Jun 13, 2015 Jun 13, 2015

Copy link to clipboard

Copied

You can select all channels with:-

activeDocument.activeChannels = activeDocument.componentChannels;

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 ,
Jun 13, 2015 Jun 13, 2015

Copy link to clipboard

Copied

Thanks for that Philip. I am not sure that will work in this case since I need to make the RGB channels active but not the channels in which I have saved selections.

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
Enthusiast ,
Jun 13, 2015 Jun 13, 2015

Copy link to clipboard

Copied

Sorry, I shouldn't have said all channels, it only selects the componant channels rgb, cmyk etc.

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 ,
Jun 13, 2015 Jun 13, 2015

Copy link to clipboard

Copied

Excellent! I will give it a try. Thanks.

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 ,
Jun 13, 2015 Jun 13, 2015

Copy link to clipboard

Copied

LATEST

Works perfectly. Thanks again.

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