[FIXED] Skript, um 1 zufällige Schicht in jeder Gruppe sichtbar zu machen [Photoshop CC2018]

Ausgabe

Ich versuche, ein Skript zu erstellen, das zufällig eine einzelne Ebene aus allen Gruppen in Photoshop auswählt und anzeigt und das Ergebnis als PNG exportiert.

Ich habe dieses Skript hier gefunden, das zu funktionieren scheint:

function Visible() {
  var Grps = app.activeDocument.layerSets; // loops through all groups
  for(var i = 0; i < Grps.length; i++){
    var tmp = app.activeDocument.layerSets[i].layers.length;
    app.activeDocument.layerSets[i].visible=true;
    var groupChildArr = app.activeDocument.layerSets[i].layers;
    var randLays = Math.floor(Math.random() * tmp);
    groupChildArr[randLays].visible = true;
    Save();
  }
  Revert();
}

function Save() {
  var outFolder = app.activeDocument; // psd name
  var outPath = outFolder.path;
  var fName = "PNG";   // define folder name
  var f = new Folder(outPath + "/" + fName);
  if ( ! f.exists ) {
    f.create()
  }
  var saveFile = new File(outPath + "/" + fName +"/" + "Pattern_" +  num + ".png");
  pngSaveOptions = new PNGSaveOptions();
  pngSaveOptions.interlaced = false;
  app.activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}

function Revert(){
  var idslct = charIDToTypeID( "slct" );
  var desc300 = new ActionDescriptor();
  var idnull = charIDToTypeID( "null" );
  var ref163 = new ActionReference();
  var idSnpS = charIDToTypeID( "SnpS" );
  ref163.putName( idSnpS, "test.psd" );
  desc300.putReference( idnull, ref163 );
  executeAction( idslct, desc300, DialogModes.NO );
}

var count = prompt("How many patterns you want","");
for (var x=0 ; x<count;x++){
  var num = x+1;
  Visible();
}
Share

Außer es gibt mir einen Fehler 8800: Allgemeiner Photoshop-Fehler aufgetreten. Diese Funktion ist in dieser Version von Photoshop möglicherweise nicht verfügbar. Zeile: 36 -> executeAction( idslct, desc300, DialogModes.NO );

Kann ich etwas tun, damit es funktioniert, da dies meinen Arbeitsprozess erheblich beschleunigen würde? Vielen Dank.

Lösung

Ohne zu sehen, wie Ihre PSD aussieht, ist es schwer zu sagen. Ich denke jedoch, dass der Code bei der Revert-Funktion fehlschlägt.

Versuchen Sie stattdessen Folgendes:

function Revert()
{
  // =======================================================
  var idRvrt = charIDToTypeID( "Rvrt" );
  executeAction( idRvrt, undefined, DialogModes.NO );
}


Beantwortet von –
Ghoul Fool


Antwort geprüft von –
Mary Flores (FixError Volunteer)

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like