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

Can you set the Alignment is script

Participant ,
Jul 12, 2021 Jul 12, 2021

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
3.3K
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

correct answers 1 Correct answer

People's Champ , 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++)
        {
     
...
Translate
Adobe
People's Champ ,
Jul 12, 2021 Jul 12, 2021

Untitled-1.png

 

Use this to paste the code!!

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

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);
} */
}

 

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
People's Champ ,
Jul 12, 2021 Jul 12, 2021
Your script does nothing for me. What is expected to happen?
 
 
 
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
Participant ,
Jul 12, 2021 Jul 12, 2021

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

1.JPG

 

 

I want this ?

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

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

 

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
People's Champ ,
Jul 12, 2021 Jul 12, 2021

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

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

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...

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
People's Champ ,
Jul 12, 2021 Jul 12, 2021
You said the script works well for you. Nothing happens to me. What's going on with you?
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
Participant ,
Jul 12, 2021 Jul 12, 2021

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)

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
People's Champ ,
Jul 12, 2021 Jul 12, 2021
I've told. Nothing happens to me. As there was one layer, it remained. I'll take a closer look at your code later.
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
Participant ,
Jul 12, 2021 Jul 12, 2021

Ok @r-bin  See you later

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
People's Champ ,
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++)
        {
        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")
???
 
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
Participant ,
Jul 12, 2021 Jul 12, 2021

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  

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
People's Champ ,
Jul 12, 2021 Jul 12, 2021

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

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

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

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
People's Champ ,
Jul 12, 2021 Jul 12, 2021
Show screenshot. I don't understand what you mean. I have a PS2020
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
Participant ,
Jul 12, 2021 Jul 12, 2021

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

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

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

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

Yaa I Know @Kukurykus 

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
People's Champ ,
Jul 12, 2021 Jul 12, 2021
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.
 
 
 
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
LEGEND ,
Jul 12, 2021 Jul 12, 2021
LATEST

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

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

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

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

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

Yes You can use Photoshop CC 2021, Because Of Old Version Photoshop "Copy " Command is 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