Copy link to clipboard
Copied
I work in patterns. I have to make 1000 patterns a day. So I am troubled by selecting every time. Can the last pattern be selected?
1 Correct answer
This should create a Pattern Layer with the last Pattern.
// create pattern layer with last pattern;
// 2023, use it at your own risk;
if (app.documents.length > 0) {
try {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID ("property"), stringIDToTypeID("presetManager") );
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var presetManager = applicationDesc.getList(stringIDToTypeID("presetMa
...
Explore related tutorials & articles
Copy link to clipboard
Copied
Selected where and how? What is the context?
Please describe in steps and add screenshots to help illustrate.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Could you please post screenshots with the pertinent Panels (Toolbar, Layers, Patterns, Options Bar, …) visible to illustrate what the point is, how you want to use that Pattern?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Please help me sir. I have been trying to solve the problem for a year.
Copy link to clipboard
Copied
This should create a Pattern Layer with the last Pattern.
// create pattern layer with last pattern;
// 2023, use it at your own risk;
if (app.documents.length > 0) {
try {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID ("property"), stringIDToTypeID("presetManager") );
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var presetManager = applicationDesc.getList(stringIDToTypeID("presetManager"));
var patternNames = presetManager.getObjectValue(4).getList(stringIDToTypeID("name"));
var theNames = new Array;
for (m = 0; m < patternNames.count; m++) {
theNames.push(patternNames.getString(m))
};
makePatternLayer (theNames[theNames.length-1], 100);
//brickFill (theNames[theNames.length-1], 0.1)
} catch (e) {};
};
////// make pattern layer //////
function makePatternLayer (thePatternName, theScale) {
// =======================================================
var idMk = charIDToTypeID( "Mk " );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
ref1.putClass( idcontentLayer );
desc3.putReference( idnull, ref1 );
var idUsng = charIDToTypeID( "Usng" );
var desc4 = new ActionDescriptor();
var idType = charIDToTypeID( "Type" );
var desc5 = new ActionDescriptor();
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
desc5.putUnitDouble( idScl, idPrc, theScale );
var idPtrn = charIDToTypeID( "Ptrn" );
var desc6 = new ActionDescriptor();
var idNm = charIDToTypeID( "Nm " );
desc6.putString( idNm, "rust400x400" );
var idIdnt = charIDToTypeID( "Nm " );
desc6.putString( idIdnt, thePatternName );
var idPtrn = charIDToTypeID( "Ptrn" );
desc5.putObject( idPtrn, idPtrn, desc6 );
var idpatternLayer = stringIDToTypeID( "patternLayer" );
desc4.putObject( idType, idpatternLayer, desc5 );
var idcontentLayer = stringIDToTypeID( "contentLayer" );
desc3.putObject( idUsng, idcontentLayer, desc4 );
executeAction( idMk, desc3, DialogModes.NO );
return app.activeDocument.activeLayer
};
Copy link to clipboard
Copied
Ohh my God....it is working..THank U.. THank u SO Much..U are Great Sir..Thank U.
Copy link to clipboard
Copied
You’re welcome!
Copy link to clipboard
Copied
You were not explicitly tagged in the last two replies, so may not be receiving notifications... Please let us know how the script from @c.pfaffenbichler works for you.
Copy link to clipboard
Copied
If you open the Patterns panel (Window > Patterns), then your most recently used pattern should appear as a small swatch at the to as well as a larger swatch below the other folders of swatches. You can click on a swatch and drag it to a selection on your canvas to apply it. Similarly, you can select a Pattern layer in the Layers panel and click on a different pattern swatch to have that pattern layer use that selected swatch instead.
Copy link to clipboard
Copied
Very nice. This is a correct method but when I use it in action, the same pattern is repeating.
Copy link to clipboard
Copied
How you want to use that Pattern?
What role is it supposed to play in the Action?
Copy link to clipboard
Copied
I replayed you above sir
Copy link to clipboard
Copied
Sorry sir. If you ever say something wrong.
Copy link to clipboard
Copied
Sorry sir. If you ever say something wrong.
That seems a bit unclear; but should the Script need changes please elaborate.
Copy link to clipboard
Copied
No sir.this script is a best script.it is working...Thank u.
Copy link to clipboard
Copied
Sorry sir.
if i ever said something wrong to you

