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

Can you set the Alignment is script

Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

ignore my post @Kukurykus  Don't read my post !

The script is worked and fine but one thing alignment is not set in script ?

Please Solve this ? @r-bin 


cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

#target photoshop;
app.bringToFront();
main()
function main(){
app.bringToFront();

var row = 2;
var column = 2;
var ldivision =10;
var corner = 5;

app.preferences.rulerUnits = Units.PIXELS; //new

var desc1 = new ActionDescriptor();
desc1.putString(sTID("copyHint"), "layers");



if(app.documents.length>0){
var doc = activeDocument;
try{
var desc1 = new ActionDescriptor();
desc1.putString(sTID("copyHint"), "layers");
var doc = activeDocument;
var sBounds = executeAction(cTID('copy'), desc1,DialogModes.NO);
var lineAdjW = ldivision/row
var lineAdjH = ldivision/column

var sWidth = (parseFloat(sBounds[2]) -parseFloat(sBounds[0]))/column - ldivision + ldivision/(row ); //modified
var sHeight = (parseFloat(sBounds[3]) -parseFloat(sBounds[1]))/row - ldivision + ldivision/(column ) ; //modified

var leftSide = parseFloat (sBounds[0]);
var topSide = parseFloat (sBounds[1]);

for(var i=0;i<row;i++) {
leftSide = parseFloat (sBounds[0]);
for(var j=0;j<column;j++){
pasteInPlace() //old code
leftSide += sWidth + ldivision
}
topSide += sHeight +ldivision
}
}
catch(e){}
}
else {alert("There is no open document!")}

function pasteInPlace() {
var desc1 = new ActionDescriptor();
desc1.putBoolean(sTID("inPlace"), true);
desc1.putEnumerated(cTID('AntA'), cTID('Annt'), cTID('Anno'));

executeAction(cTID('past'), desc1, DialogModes.NO);
// Create_Rectangle(t,l,b,r, corner)
};

/*function Create_Rectangle(t,l,b,r, corner) {
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var ref1 = new ActionReference();
ref1.putClass(sTID("contentLayer"));
desc1.putReference(cTID("null"), ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
var desc4 = new ActionDescriptor();
desc4.putDouble(cTID("Rd "), 0);
desc4.putDouble(cTID("Grn "), 0);
desc4.putDouble(cTID("Bl "), 0);
desc3.putObject(cTID("Clr "), sTID("RGBColor"), desc4);
desc2.putObject(cTID("Type"), sTID("solidColorLayer"), desc3);
var desc5 = new ActionDescriptor();
desc5.putInteger(sTID("unitValueQuadVersion"), 1);
desc5.putUnitDouble(cTID("Top "), cTID("#Pxl"), t );
desc5.putUnitDouble(cTID("Left"), cTID("#Pxl"), l );
desc5.putUnitDouble(cTID("Btom"), cTID("#Pxl"), b );
desc5.putUnitDouble(cTID("Rght"), cTID("#Pxl"), r );
desc5.putUnitDouble(sTID("topRight"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("topLeft"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("bottomLeft"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("bottomRight"), cTID("#Pxl"), corner);
desc2.putObject(cTID("Shp "), cTID("Rctn"), desc5);
desc1.putObject(cTID("Usng"), sTID("contentLayer"), desc2);
executeAction(cTID("Mk "), desc1, DialogModes.NO);
} */
}

TOPICS
Actions and scripting

Views

1.2K

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

correct answers 1 Correct answer

Valorous Hero , Jul 12, 2021 Jul 12, 2021
Everything that I understood from your pictures and words.
If not, then describe in detail, and not in "two words".
 
var rows = 2;
var clms = 2;

var gap_h = UnitValue(1, "mm");
var gap_v = UnitValue(2, "mm");

var layer0 = activeDocument.activeLayer;

var dx = layer0.bounds[2]-layer0.bounds[0] + gap_h.as(layer0.bounds[0].type);
var dy = layer0.bounds[3]-layer0.bounds[1] + gap_v.as(layer0.bounds[0].type);

for (var r = 0; r < rows; r++)
    {
    for (var c = 0; c < clms; c++)
        {
     
...

Votes

Translate

Translate
Adobe
Valorous Hero ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied


Untitled-1.png

 

Use this to paste the code!!

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Ok @r-bin 

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

#target photoshop;
app.bringToFront();
main()
function main(){
app.bringToFront();

var row = 2;
var column = 2;
var ldivision =10;
var corner = 5;

app.preferences.rulerUnits = Units.PIXELS; //new

var desc1 = new ActionDescriptor();
desc1.putString(sTID("copyHint"), "layers");



if(app.documents.length>0){
var doc = activeDocument;
try{
var desc1 = new ActionDescriptor();
desc1.putString(sTID("copyHint"), "layers");
var doc = activeDocument;
var sBounds = executeAction(cTID('copy'), desc1,DialogModes.NO);
var lineAdjW = ldivision/row
var lineAdjH = ldivision/column

var sWidth = (parseFloat(sBounds[2]) -parseFloat(sBounds[0]))/column - ldivision + ldivision/(row ); //modified
var sHeight = (parseFloat(sBounds[3]) -parseFloat(sBounds[1]))/row - ldivision + ldivision/(column ) ; //modified

var leftSide = parseFloat (sBounds[0]);
var topSide = parseFloat (sBounds[1]);

for(var i=0;i<row;i++) {
leftSide = parseFloat (sBounds[0]);
for(var j=0;j<column;j++){
pasteInPlace() //old code
leftSide += sWidth + ldivision
}
topSide += sHeight +ldivision
}
}
catch(e){}
}
else {alert("There is no open document!")}

function pasteInPlace() {
var desc1 = new ActionDescriptor();
desc1.putBoolean(sTID("inPlace"), true);
desc1.putEnumerated(cTID('AntA'), cTID('Annt'), cTID('Anno'));

executeAction(cTID('past'), desc1, DialogModes.NO);
// Create_Rectangle(t,l,b,r, corner)
};

/*function Create_Rectangle(t,l,b,r, corner) {
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var ref1 = new ActionReference();
ref1.putClass(sTID("contentLayer"));
desc1.putReference(cTID("null"), ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
var desc4 = new ActionDescriptor();
desc4.putDouble(cTID("Rd "), 0);
desc4.putDouble(cTID("Grn "), 0);
desc4.putDouble(cTID("Bl "), 0);
desc3.putObject(cTID("Clr "), sTID("RGBColor"), desc4);
desc2.putObject(cTID("Type"), sTID("solidColorLayer"), desc3);
var desc5 = new ActionDescriptor();
desc5.putInteger(sTID("unitValueQuadVersion"), 1);
desc5.putUnitDouble(cTID("Top "), cTID("#Pxl"), t );
desc5.putUnitDouble(cTID("Left"), cTID("#Pxl"), l );
desc5.putUnitDouble(cTID("Btom"), cTID("#Pxl"), b );
desc5.putUnitDouble(cTID("Rght"), cTID("#Pxl"), r );
desc5.putUnitDouble(sTID("topRight"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("topLeft"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("bottomLeft"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("bottomRight"), cTID("#Pxl"), corner);
desc2.putObject(cTID("Shp "), cTID("Rctn"), desc5);
desc1.putObject(cTID("Usng"), sTID("contentLayer"), desc2);
executeAction(cTID("Mk "), desc1, DialogModes.NO);
} */
}

 

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
Valorous Hero ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Your script does nothing for me. What is expected to happen?
 
 
 

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Run the Script :- Layer will divided on Layer Panel But alignment will not set ?

1.JPG

 

 

I want this ?

2.JPG

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Step 1:- I have One Layer .

Step 2:- The Layer will copy number of rows and number of column in script ?

Step 3:- Set the alignment For Distance Space

 

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
Valorous Hero ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Ah, I seem to understand. I'll see later. But your script, in my opinion, does nothing at all.

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
LEGEND ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Once you asked to make videos for you 😕 Well maybe that's time to illustrate your manual Photoshop doings to get the goal by making video yourself? Do it to help your helpers...

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
Valorous Hero ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

You said the script works well for you. Nothing happens to me. What's going on with you?

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

One Problem Of Script :- Alignment will not set 

 

Step 1:- I have One Layer .

Step 2:- The Layer will copy number of rows and number of column in script ?

Step 3:- Set the alignment For Distance Space ( I want this)

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
Valorous Hero ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

I've told. Nothing happens to me. As there was one layer, it remained. I'll take a closer look at your code later.

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Ok @r-bin  See you later

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
Valorous Hero ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Everything that I understood from your pictures and words.
If not, then describe in detail, and not in "two words".
 
var rows = 2;
var clms = 2;

var gap_h = UnitValue(1, "mm");
var gap_v = UnitValue(2, "mm");

var layer0 = activeDocument.activeLayer;

var dx = layer0.bounds[2]-layer0.bounds[0] + gap_h.as(layer0.bounds[0].type);
var dy = layer0.bounds[3]-layer0.bounds[1] + gap_v.as(layer0.bounds[0].type);

for (var r = 0; r < rows; r++)
    {
    for (var c = 0; c < clms; c++)
        {
        if (!r && !c) continue;

        var layer1 = layer0.duplicate();
        
        layer1.translate(dx*c, dy*r);
        }
    }
 
P.S. Where did you get this code.
What is
desc1.putString(sTID("copyHint"), "layers")
???
 

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Thanks for Code !

function Copy() {
  // Copy
  function step1(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putString(sTID("copyHint"), "layers");
    executeAction(cTID('copy'), desc1, dialogMode);
  };

  step1();      // Copy
};

 

I have created For Copy in Action Listener  

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
Valorous Hero ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

What menu item did you perform when you recorded this action?

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

For Layer Copy , To set no. of rows and no. of column

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
Valorous Hero ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Show screenshot. I don't understand what you mean. I have a PS2020

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Copy A Layer in PS 2021, I think It's new command of PS 2021

copp.JPG

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
LEGEND ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

When layer is selected you get 'layers', when selection then 'pixels', when path then 'path'.

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Yaa I Know @Kukurykus 

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
Valorous Hero ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

I do not have that. Perhaps this is an auxiliary parameter that does not particularly affect anything. If the descriptor is not empty for copyEvent, then an error is thrown in 2020.
 
 
 

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
LEGEND ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

LATEST

That's true. When you make selection and use that code with 'layers', it still copies pixels.

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Thanks @r-bin  Code is very well And Worked Fine

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 ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Thet script fails in old photoshop versions 

 

var sBounds = executeAction(cTID('copy'), desc1,DialogModes.NO);

// catch(e){}
catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }

 

image.png

JJMack

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
Participant ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Yes You can use Photoshop CC 2021, Because Of Old Version Photoshop "Copy " Command is not working ?

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