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

Create Patterns based on an image and Accessing patterns (and pattern groups) via scripting

Explorer ,
Apr 06, 2023 Apr 06, 2023

Copy link to clipboard

Copied

Hi, 
Basically, i am trying to achieve 2 things.

1. (Ideal, but can be optional) Make a script that allows me to create a Pattern(tile image) based on an img i provide
2. (Minimum ideal functionality )Make the script access the pattern folders i specify for it to loop the patterns already created and place them on the specified layer, then save one by one.

 

I havent found a way to access the Patterns or pattern groups, is this possible?

 

This script does the following:

  1. Asks the user to select an image folder and an export folder.
  2. Opens the first image found in the image folder.
  3. Applies the chosen patterns to a specified layer on the active document
  4. Saves the active document as a PNG file in the export folder.
  5. Closes the document
TOPICS
Actions and scripting , Windows

Views

353

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
Adobe
Contributor ,
Apr 07, 2023 Apr 07, 2023

Copy link to clipboard

Copied

Look into this...

 

https://substance3d.adobe.com/documentation/sddoc

 

You're gonna love 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
Explorer ,
Apr 07, 2023 Apr 07, 2023

Copy link to clipboard

Copied

Thanks for sharing! Although, it is not exactly what am i looking for 😄

 

I already have the patterns created, the tiles, so to speak, in images 1000x1000 px. All i need is photoshop to take these images and fill a an already document canvas with it and save it as a png. 🙂

 

I can do the saving and looking for the image my self in the script, just cant figure out the script action or function name to make photoshop do this procedure of the tiles with the images i have.

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
Contributor ,
Apr 07, 2023 Apr 07, 2023

Copy link to clipboard

Copied

Oh right, i see. My bad. 🙂

Can you already define how the patterns will be chosen and how the layer(s) will be specified?

 

One thing to get started with is this: This links to a script on github that uses patterns 

You could use it as a starting point for some inspiration. 🙂

 

 

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 ,
Apr 07, 2023 Apr 07, 2023

Copy link to clipboard

Copied

LATEST

Don’t have the link, but this Script was created by @Paul Riggott and creates Layers from the Patterns in a pat-file: 

// by paul riggott;
#target photoshop
main();
function main(){
var file = File.openDialog("Please select Pat file");  
if(file == null) return;
if(!documents.length){
   var doc = app.documents.add(UnitValue(300, "px"), UnitValue(300, "px"),72,"Patterns");
}
  file.open("r");
  file.encoding = 'BINARY';
  var str = file.read();
  file.close();
  var patterns=[];
  //Thanks to X for the regex
  var re = /(\x00\w|\x00\d)(\x00\-|\x00\w|\x00\s|\x00\d)+\x00\x00\$[-a-z\d]+/g;
  var parts = str.match(re);
  for (var i = 0; i < parts.length; i++) {
    var p = parts[i];
    var sp = p.replace(/\x00/g, '').split('$');
     patterns.push([[sp[0]], [sp[1]]]);   
      }
  //load pattern file
  app.load(file);
for(var a in patterns){
fillPattern(patterns[a][0].toString(),patterns[a][1].toString(),100);  
    }
};
function fillPattern(name, id, opacity) { 
    activeDocument.artLayers.add(); 
    activeDocument.activeLayer.name = name;
    var desc6 = new ActionDescriptor(); 
    desc6.putEnumerated( charIDToTypeID('Usng'), charIDToTypeID('FlCn'), charIDToTypeID('Ptrn') ); 
        var desc7 = new ActionDescriptor(); 
        desc7.putString( charIDToTypeID('Nm  '), name ); 
        desc7.putString( charIDToTypeID('Idnt'), id); 
    desc6.putObject( charIDToTypeID('Ptrn'), charIDToTypeID('Ptrn'), desc7 ); 
    desc6.putUnitDouble( charIDToTypeID('Opct'), charIDToTypeID('#Prc'), opacity ); 
    desc6.putEnumerated( charIDToTypeID('Md  '), charIDToTypeID('BlnM'), charIDToTypeID('Nrml') ); 
    try{
    executeAction( charIDToTypeID('Fl  '), desc6, DialogModes.NO ); 
    activeDocument.activeLayer.visible=false;
    }catch(e){app.activeDocument.activeLayer.remove();}
};

 

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