skip to Main Content

I’ve got some code with the ScriptListner plugin for Photoshop. I’m trying to use the “document.getElementById('id').path = 'some path'” with ExtendScript, which is actually just modified JavaScript (as far as I know) but Photoshop JavaScript engine does not seem to support that.

I’ve tried to change the ‘document’ with ‘app.activeDocumnt’ but that’s not helping

function BuildContactSheet(sourceeFolder) {
  var idzeroBsevenoneDtwotwooneFeightCEoneonedtwoBtwooneBzerozerozeroeightCsevenfiveBthreetwotwoC = stringIDToTypeID("0B71D221-F8CE-11d2-B21B-0008C75B322C");
  var desc2 = new ActionDescriptor();
  var idCSIISettings = stringIDToTypeID("CSIISettings");
  desc2.putString(idCSIISettings, ""
    "<ContactSheetIISettings> <
    source id = "outPathsrc"
    imageSource = "Folder"
    path = "e"
    includeSubfolders = "false"
    groupImages = "false" / >
    <
    document units = "inches"
    width = "1.5"
    height = "2.4"
    resolution = "150"
    resUnits = "pixels/inch"
    mode = "RGB Color"
    bitDepth = "8-bit"
    colorProfile = "sRGB IEC61966-2.1"
    flattenLayers = "true" / >
    <
    thumbnail place = "across first"
    cols = "1"
    rows = "4"
    bestFit = "false"
    useAutospacing = "false"
    horz = "0.039 in"
    vert = "0.039 in" / >
    <
    caption enabled = "false" >
    <
    font name = "ArialMT"
    size = "12" / >
    <
    /caption> < /
    ContactSheetIISettings > ""
    " );
    var idMsge = charIDToTypeID("Msge"); desc2.putString(idMsge, ""
      "Settings for Contact Sheet II"
      ""); activeDocument.getElementById("outPathsrc").path = sourceeFolder;

    executeAction(idzeroBsevenoneDtwotwooneFeightCEoneonedtwoBtwooneBzerozerozeroeightCsevenfiveBthreetwotwoC, desc2, DialogModes.NO);

  }

This code code should have worked and changed the source folder according to the argument that I pass in the function but that does not work. Instead it shows the following error:

Error 1302: No such element
Line: 113
         activeDocument.getElementById("outPathsrc").path = sourceeFolder;

EDIT :
I previously tried this and it worked,I was able to pass argument to the function!

‘code’

function dividePic(outFolder){
    var idExpr = charIDToTypeID( "Expr" );
        var desc104 = new ActionDescriptor();
        var idUsng = charIDToTypeID( "Usng" );
            var desc105 = new ActionDescriptor();
            var idOp = charIDToTypeID( "Op  " );
            var idSWOp = charIDToTypeID( "SWOp" );
            var idOpSa = charIDToTypeID( "OpSa" );
            desc105.putEnumerated( idOp, idSWOp, idOpSa );
            var idDIDr = charIDToTypeID( "DIDr" );
            desc105.putBoolean( idDIDr, true );
            var idIn = charIDToTypeID( "In  " );
            desc105.putPath( idIn, new File(outFolder) ); //THE ARGUMENT IS HERE!!!!
            var idFmt = charIDToTypeID( "Fmt " );
            var idIRFm = charIDToTypeID( "IRFm" );
            var idJPEG = charIDToTypeID( "JPEG" );
            desc105.putEnumerated( idFmt, idIRFm, idJPEG );
            var idIntr = charIDToTypeID( "Intr" );
            desc105.putBoolean( idIntr, false );
            var idQlty = charIDToTypeID( "Qlty" );
            desc105.putInteger( idQlty, 30 );
            var idQChS = charIDToTypeID( "QChS" );
            desc105.putInteger( idQChS, 0 );
            var idQCUI = charIDToTypeID( "QCUI" );
            desc105.putInteger( idQCUI, 0 );
            var idQChT = charIDToTypeID( "QChT" );
            desc105.putBoolean( idQChT, false );
            var idQChV = charIDToTypeID( "QChV" );
            desc105.putBoolean( idQChV, false );
            var idOptm = charIDToTypeID( "Optm" );
            desc105.putBoolean( idOptm, true );
            var idPass = charIDToTypeID( "Pass" );
            desc105.putInteger( idPass, 1 );
            var idblur = charIDToTypeID( "blur" );
            desc105.putDouble( idblur, 0.000000 );
            var idMtt = charIDToTypeID( "Mtt " );
            desc105.putBoolean( idMtt, true );
            var idEICC = charIDToTypeID( "EICC" );
            desc105.putBoolean( idEICC, false );
            var idMttR = charIDToTypeID( "MttR" );
            desc105.putInteger( idMttR, 255 );
            var idMttG = charIDToTypeID( "MttG" );
            desc105.putInteger( idMttG, 255 );
            var idMttB = charIDToTypeID( "MttB" );
            desc105.putInteger( idMttB, 255 );
            var idSHTM = charIDToTypeID( "SHTM" );
            desc105.putBoolean( idSHTM, false );
            var idSImg = charIDToTypeID( "SImg" );
            desc105.putBoolean( idSImg, true );
            var idSWsl = charIDToTypeID( "SWsl" );
            var idSTsl = charIDToTypeID( "STsl" );
            var idSLAl = charIDToTypeID( "SLAl" );
            desc105.putEnumerated( idSWsl, idSTsl, idSLAl );
            var idSWch = charIDToTypeID( "SWch" );
            var idSTch = charIDToTypeID( "STch" );
            var idCHsR = charIDToTypeID( "CHsR" );
            desc105.putEnumerated( idSWch, idSTch, idCHsR );
            var idSWmd = charIDToTypeID( "SWmd" );
            var idSTmd = charIDToTypeID( "STmd" );
            var idMDCC = charIDToTypeID( "MDCC" );
            desc105.putEnumerated( idSWmd, idSTmd, idMDCC );
            var idohXH = charIDToTypeID( "ohXH" );
            desc105.putBoolean( idohXH, false );
            var idohIC = charIDToTypeID( "ohIC" );
            desc105.putBoolean( idohIC, true );
            var idohAA = charIDToTypeID( "ohAA" );
            desc105.putBoolean( idohAA, true );
            var idohQA = charIDToTypeID( "ohQA" );
            desc105.putBoolean( idohQA, true );
            var idohCA = charIDToTypeID( "ohCA" );
            desc105.putBoolean( idohCA, false );
            var idohIZ = charIDToTypeID( "ohIZ" );
            desc105.putBoolean( idohIZ, true );
            var idohTC = charIDToTypeID( "ohTC" );
            var idSToc = charIDToTypeID( "SToc" );
            var idOCzerothree = charIDToTypeID( "OC03" );
            desc105.putEnumerated( idohTC, idSToc, idOCzerothree );
            var idohAC = charIDToTypeID( "ohAC" );
            var idSToc = charIDToTypeID( "SToc" );
            var idOCzerothree = charIDToTypeID( "OC03" );
            desc105.putEnumerated( idohAC, idSToc, idOCzerothree );
            var idohIn = charIDToTypeID( "ohIn" );
            desc105.putInteger( idohIn, -1 );
            var idohLE = charIDToTypeID( "ohLE" );
            var idSTle = charIDToTypeID( "STle" );
            var idLEzerothree = charIDToTypeID( "LE03" );
            desc105.putEnumerated( idohLE, idSTle, idLEzerothree );
            var idohEn = charIDToTypeID( "ohEn" );
            var idSTen = charIDToTypeID( "STen" );
            var idENzerozero = charIDToTypeID( "EN00" );
            desc105.putEnumerated( idohEn, idSTen, idENzerozero );
            var idolCS = charIDToTypeID( "olCS" );
            desc105.putBoolean( idolCS, false );
            var idolEC = charIDToTypeID( "olEC" );
            var idSTst = charIDToTypeID( "STst" );
            var idSTzerozero = charIDToTypeID( "ST00" );
            desc105.putEnumerated( idolEC, idSTst, idSTzerozero );
            var idolWH = charIDToTypeID( "olWH" );
            var idSTwh = charIDToTypeID( "STwh" );
            var idWHzeroone = charIDToTypeID( "WH01" );
            desc105.putEnumerated( idolWH, idSTwh, idWHzeroone );
            var idolSV = charIDToTypeID( "olSV" );
            var idSTsp = charIDToTypeID( "STsp" );
            var idSPzerofour = charIDToTypeID( "SP04" );
            desc105.putEnumerated( idolSV, idSTsp, idSPzerofour );
            var idolSH = charIDToTypeID( "olSH" );
            var idSTsp = charIDToTypeID( "STsp" );
            var idSPzerofour = charIDToTypeID( "SP04" );
            desc105.putEnumerated( idolSH, idSTsp, idSPzerofour );
            var idolNC = charIDToTypeID( "olNC" );
                var list5 = new ActionList();
                    var desc106 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCzerozero = charIDToTypeID( "NC00" );
                    desc106.putEnumerated( idncTp, idSTnc, idNCzerozero );
                var idSCnc = charIDToTypeID( "SCnc" );
                list5.putObject( idSCnc, desc106 );
                    var desc107 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNConenine = charIDToTypeID( "NC19" );
                    desc107.putEnumerated( idncTp, idSTnc, idNConenine );
                var idSCnc = charIDToTypeID( "SCnc" );
                list5.putObject( idSCnc, desc107 );
                    var desc108 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCtwoeight = charIDToTypeID( "NC28" );
                    desc108.putEnumerated( idncTp, idSTnc, idNCtwoeight );
                var idSCnc = charIDToTypeID( "SCnc" );
                list5.putObject( idSCnc, desc108 );
                    var desc109 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCtwofour = charIDToTypeID( "NC24" );
                    desc109.putEnumerated( idncTp, idSTnc, idNCtwofour );
                var idSCnc = charIDToTypeID( "SCnc" );
                list5.putObject( idSCnc, desc109 );
                    var desc110 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCtwofour = charIDToTypeID( "NC24" );
                    desc110.putEnumerated( idncTp, idSTnc, idNCtwofour );
                var idSCnc = charIDToTypeID( "SCnc" );
                list5.putObject( idSCnc, desc110 );
                    var desc111 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCtwofour = charIDToTypeID( "NC24" );
                    desc111.putEnumerated( idncTp, idSTnc, idNCtwofour );
                var idSCnc = charIDToTypeID( "SCnc" );
                list5.putObject( idSCnc, desc111 );
            desc105.putList( idolNC, list5 );
            var idobIA = charIDToTypeID( "obIA" );
            desc105.putBoolean( idobIA, false );
            var idobIP = charIDToTypeID( "obIP" );
            desc105.putString( idobIP, """""" );
            var idobCS = charIDToTypeID( "obCS" );
            var idSTcs = charIDToTypeID( "STcs" );
            var idCSzeroone = charIDToTypeID( "CS01" );
            desc105.putEnumerated( idobCS, idSTcs, idCSzeroone );
            var idovNC = charIDToTypeID( "ovNC" );
                var list6 = new ActionList();
                    var desc112 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCzeroone = charIDToTypeID( "NC01" );
                    desc112.putEnumerated( idncTp, idSTnc, idNCzeroone );
                var idSCnc = charIDToTypeID( "SCnc" );
                list6.putObject( idSCnc, desc112 );
                    var desc113 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCtwozero = charIDToTypeID( "NC20" );
                    desc113.putEnumerated( idncTp, idSTnc, idNCtwozero );
                var idSCnc = charIDToTypeID( "SCnc" );
                list6.putObject( idSCnc, desc113 );
                    var desc114 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCzerotwo = charIDToTypeID( "NC02" );
                    desc114.putEnumerated( idncTp, idSTnc, idNCzerotwo );
                var idSCnc = charIDToTypeID( "SCnc" );
                list6.putObject( idSCnc, desc114 );
                    var desc115 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNConenine = charIDToTypeID( "NC19" );
                    desc115.putEnumerated( idncTp, idSTnc, idNConenine );
                var idSCnc = charIDToTypeID( "SCnc" );
                list6.putObject( idSCnc, desc115 );
                    var desc116 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCzerosix = charIDToTypeID( "NC06" );
                    desc116.putEnumerated( idncTp, idSTnc, idNCzerosix );
                var idSCnc = charIDToTypeID( "SCnc" );
                list6.putObject( idSCnc, desc116 );
                    var desc117 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCtwofour = charIDToTypeID( "NC24" );
                    desc117.putEnumerated( idncTp, idSTnc, idNCtwofour );
                var idSCnc = charIDToTypeID( "SCnc" );
                list6.putObject( idSCnc, desc117 );
                    var desc118 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCtwofour = charIDToTypeID( "NC24" );
                    desc118.putEnumerated( idncTp, idSTnc, idNCtwofour );
                var idSCnc = charIDToTypeID( "SCnc" );
                list6.putObject( idSCnc, desc118 );
                    var desc119 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCtwofour = charIDToTypeID( "NC24" );
                    desc119.putEnumerated( idncTp, idSTnc, idNCtwofour );
                var idSCnc = charIDToTypeID( "SCnc" );
                list6.putObject( idSCnc, desc119 );
                    var desc120 = new ActionDescriptor();
                    var idncTp = charIDToTypeID( "ncTp" );
                    var idSTnc = charIDToTypeID( "STnc" );
                    var idNCtwotwo = charIDToTypeID( "NC22" );
                    desc120.putEnumerated( idncTp, idSTnc, idNCtwotwo );
                var idSCnc = charIDToTypeID( "SCnc" );
                list6.putObject( idSCnc, desc120 );
            desc105.putList( idovNC, list6 );
            var idovCM = charIDToTypeID( "ovCM" );
            desc105.putBoolean( idovCM, false );
            var idovCW = charIDToTypeID( "ovCW" );
            desc105.putBoolean( idovCW, true );
            var idovCU = charIDToTypeID( "ovCU" );
            desc105.putBoolean( idovCU, true );
            var idovSF = charIDToTypeID( "ovSF" );
            desc105.putBoolean( idovSF, true );
            var idovCB = charIDToTypeID( "ovCB" );
            desc105.putBoolean( idovCB, true );
            var idovSN = charIDToTypeID( "ovSN" );
            desc105.putString( idovSN, """images""" );
        var idSaveForWeb = stringIDToTypeID( "SaveForWeb" );
        desc104.putObject( idUsng, idSaveForWeb, desc105 );
    executeAction( idExpr, desc104, DialogModes.NO );

}

‘code’

2

Answers


  1. .getElementById is a html DOM method, photoshop doesn’t support it. You can check https://www.adobe.com/content/dam/acom/en/devnet/photoshop/pdfs/photoshop-cc-javascript-ref-2019.pdf to see what methods are supported. Alao you can’t really mix photoshop DOM and action manager code (a lower-level code you’re getting from scriptlistener).

    Login or Signup to reply.
  2. I’m not 100% sure what you’re trying to do, but if you’re talking about paths as in file paths, this would be an example of reading the contents of a folder:

    var folder = new Folder("~/Desktop/Test Folder/");
    var files = folder.getFiles();
    

    If you’re trying to get the path to the active document, that’s app.activeDocument.path

    As Sergey said, altering script listener code can be pretty fiddly.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search