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

fill with auto creat pattern and fill pattern script

Contributor ,
Aug 30, 2023 Aug 30, 2023

Hello guys, I need a bit of help to automate my work.

 

I work with patterns (as a pattern designer), but I need to slightly automate my work.

 

There is this great function now "fill with ... pattern" and then you have scripts for those.

This said what I usually do is that I wokr on a couple of patterns, make the design then test test them on a big format blank file.

so

1. I do my drawing, then

2. click "define as a new pattern" and then

3. I open a fresh new fbig big file and

4. use "fill it with... pattern" and

5. select the last one I created...

So I tried to create an action / script so that I could you know, work in batches, having to decide which of the patterns are good on a big format only later.

AND HERE COMES THE BUG!

 

When I Added exactly the same steps in the actions macro - it will work for the first file, but for the second it will still use the same pattern used previously, as the actions macro sees it as "fill it with pattern XXX" (namely, not as "last one used"), so I land up with all of the pictures in big format filled with the same pattern instead of different ones.

 

I was thinking about then modifying the macro so when I g oto step 4

4. use "fill it with... pattern" and

add " use script" among the scripts loading there, that would define something like "use the last pattern defined" - can be as well a code as "use newest pattern defined" or "use newest pattern added to the lot"

 

I understand the logic but I have no clue how to edit the scripts in this area.

 

This will save me hours of work, so all of your help will be more than appreciated.

TOPICS
Actions and scripting , Windows
4.8K
Translate
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 ,
Aug 31, 2023 Aug 31, 2023

If I just remove the pattern name word, will this script work?

Translate
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 ,
Aug 31, 2023 Aug 31, 2023

Please stop posting nonsense. 

What is the code you are using now and how does it fail? 

Translate
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 ,
Aug 31, 2023 Aug 31, 2023

I don't want help.bye

Translate
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 ,
Aug 31, 2023 Aug 31, 2023

don't have solution so don't waste my time

Translate
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 ,
Aug 31, 2023 Aug 31, 2023
quote

don't have solution so don't waste my time

You have repeatedly failed to answer my questions so please don’t act huffy. 

 

I am willing to provide advice but if adapting the Script I posted previously to do a Brick Fill (after you already successfully recorded the code) instead of creating a Pattern Layer is too difficult for you then I guess you can

• either hope someone else will take enough of an interest to do the work for you

• or familiarize yourself with Scripting a bit more. 

createBrickFillWithLastPattern.gif

 

Translate
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 ,
Aug 31, 2023 Aug 31, 2023

I saw you started another thread on the issue. 

In general double-threads are discouraged, but on that one you provided a somewhat better description of the process right away and refrained from incorrectly calling something a »bug«, so hopefully someone else will try to help you further. 

 

Good luck! 

Translate
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 ,
Aug 31, 2023 Aug 31, 2023

I am a designer. I have to work in patterns. That's why I need such a script that I make the pattern in the last, the same pattern should be fillUntitled-1.jpg. The same pattern should not be fill again and again.

Translate
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 Beginner ,
Aug 31, 2023 Aug 31, 2023

hello, maybe this scripts works for you.

You need to save this script in a .jsx and put in your actions after the pattern creation action, this scripts will aways fill with the lastest pattern created:

 

___________________________________

 

#target photoshop;


main();

function main(){

if(!documents.length) return;

var patt = new File(Folder.temp + "/tempPatterns");

if(patt.exists) patt.remove();

savePatterns(patt);

var patterns = getPatternsFromFile(patt);

fillPattern(patterns[patterns.length-1][0].toString(),patterns[patterns.length-1][1].toString(), 100);

};

function savePatterns(file) {

var desc625 = new ActionDescriptor();

desc625.putPath( charIDToTypeID('null'), new File( file ) );

var ref462 = new ActionReference();

ref462.putProperty( charIDToTypeID('Prpr'), charIDToTypeID('Ptrn') );

ref462.putEnumerated( charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

desc625.putReference( charIDToTypeID('T '), ref462 );

executeAction( charIDToTypeID('setd'), desc625, DialogModes.NO );

};

function getPatternsFromFile(file){


file.open("r");

file.encoding = 'BINARY';

var str = file.read();

file.close();

var patterns=[];

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]]]);

}

return patterns;

};

function fillPattern(name, id, opacity) {

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 );

}catch(e){}

};

Translate
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 ,
Sep 01, 2023 Sep 01, 2023

sir,This error has occurred.Screenshot 2023-09-02 102948.jpg

Translate
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 ,
Aug 31, 2023 Aug 31, 2023

What the hey … I’ll try once more: 

Screenshot 2023-09-01 at 08.43.55.jpg

Translate
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 ,
Oct 01, 2023 Oct 01, 2023

I can't understand what you are saying.please explain me

Translate
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 ,
Oct 01, 2023 Oct 01, 2023

I explained about as clearly as seemed feasible. 

Translate
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 ,
Oct 01, 2023 Oct 01, 2023

Screenshot 2023-10-01 174600.jpgerror 

Translate
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 ,
Oct 01, 2023 Oct 01, 2023

Please post the actual code you are using and the image file on which the error happens. 

Translate
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 ,
Oct 01, 2023 Oct 01, 2023

ok

Translate
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 ,
Oct 01, 2023 Oct 01, 2023

Screenshot 2023-10-02 103315.jpgthis error

Translate
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 ,
Oct 01, 2023 Oct 01, 2023

Screenshot 2023-10-02 103343.jpgCode

Translate
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 ,
Oct 01, 2023 Oct 01, 2023

If I ask for the code I mean the code, not a screenshot of the code. 

I find this conversation quite frustrating. 

Translate
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 ,
Oct 01, 2023 Oct 01, 2023
// =======================================================
var idFl = charIDToTypeID( "Fl  " );
    var desc246 = new ActionDescriptor();
    var idUsng = charIDToTypeID( "Usng" );
    var idFlCn = charIDToTypeID( "FlCn" );
    var idPtrn = charIDToTypeID( "Ptrn" );
    desc246.putEnumerated( idUsng, idFlCn, idPtrn );
    var idPtrn = charIDToTypeID( "Ptrn" );
        var desc247 = new ActionDescriptor();
        var idNm = charIDToTypeID( "Nm  " );
        desc247.putString( idNm, """thePatternName""" );
    var idPtrn = charIDToTypeID( "Ptrn" );
    desc246.putObject( idPtrn, idPtrn, desc247 );
    var idOpct = charIDToTypeID( "Opct" );
    var idPrc = charIDToTypeID( "#Prc" );
    desc246.putUnitDouble( idOpct, idPrc, 100.000000 );
    var idMd = charIDToTypeID( "Md  " );
    var idBlnM = charIDToTypeID( "BlnM" );
    var idNrml = charIDToTypeID( "Nrml" );
    desc246.putEnumerated( idMd, idBlnM, idNrml );
    var iddecoScriptFile = stringIDToTypeID( "decoScriptFile" );
    desc246.putPath( iddecoScriptFile, new File( "C:\\Program Files\\Adobe\\Adobe Photoshop 2022\\Presets\\deco\\Brick Fill.jsx" ) );
    var iddecoScriptParameters = stringIDToTypeID( "decoScriptParameters" );
    desc246.putString( iddecoScriptParameters, """({patternScale:1, offset:-100, spacing:0, colorRandomness:0, brightnessRandomness:0, rotateAngle:0})""" );
executeAction( idFl, desc246, DialogModes.NO );
Translate
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 ,
Oct 01, 2023 Oct 01, 2023

Is the name of the Pattern actually »thePatternName«? 

Why is a Pattern Layer selected and not a plain pixel Layer? 

Translate
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 ,
Oct 02, 2023 Oct 02, 2023

Sir, I have taken one pattern layer so that the last pattern feels automatic.

Translate
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 ,
Oct 02, 2023 Oct 02, 2023

And the pattern name changes every time. The pattern I create is saved with a different name. so what code can we keep for that

 

Translate
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 ,
Oct 02, 2023 Oct 02, 2023

Now I saved the pattern with the name >>thePatternName<< but the script Not working

 

Translate
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 ,
Oct 02, 2023 Oct 02, 2023
quote

Sir, I have taken one pattern layer so that the last pattern feels automatic.


By @MJ ST

Scripted Patterns do not work on Pattern Layers, so please think the process through and provide a meaningful starting position within the file so the Script can perform the intended tasks. 

Otherwise you need to include checks in the Script to compensate for the unfit situation, like an if-clause to check the viability of the active layer and create a useful one if necessary. 

 

Translate
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 ,
Oct 02, 2023 Oct 02, 2023
LATEST

ok

 

Translate
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