Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


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

409

Likes

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

Adobe Community Professional , 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++) { ...

Likes

Translate

Translate
Adobe Community Professional ,
Jul 12, 2021 Jul 12, 2021

Copy link to clipboard

Copied

Additionally use Hindi, your native language, so we can translate it and hopefully we'll avoid to guess what you mean! You become annoying, but it's still place for you, just listen the suggestions and we can move on. OKAY?!

Likes

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

No No @Kukurykus  I will speak english properly without any mistake ok

Likes

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

Copy link to clipboard

Copied

If you are able to do so then fine. I have no problem with, and that would be best. But you showed it makes many misunderstandings and people have hard time with you. If that will work then okey, if not then Hindi. There are other issues, but let's start with it for beginning.

Likes

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

@Kukurykus  I will try to Best Speak in English 

Could you not understand then tell me 

Likes

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

Copy link to clipboard

Copied

The way it look to me is because we have problems undetstabding what you write.  Give us a bad most likely wrong view of you

 

If you want a custom script you should learn how the design and code scripts or employ a programmers to programs them for you.  It fine to use this forum to asked for help witting code when you having problem scripting something. There are several knowledgeable users here that will help you.  However it not proper ask users to work for you without compensation.  The person that should modify that script is the person that want it you.   That is what I do.  I have been helped here many times by users like r-bin, supermerlin, jazz-y, Kukurykus, Chuck Uebele, c.pfaffenbichler and I like to think I have help other here also. 

 

You most like know haw to script better than me. I only hack at script I do not know javascript  so some methods I see in code are greek to me.

 

The script does some paste in place in 22.4.2 seem to create four dupe layers for two rows and columns. The Copy used is not available in prior Photoshop versions. Seems to return the current layer bounds that is copied to the clipboard. The bounds seems to be used with parseFloat( whatever that does to do some alignment. But I see no selection being set or positioning being past to the pasteinPlace() function. I just see four duped layers created.

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){}
		catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }
	}
	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);
	}
	*/
JJMack

Likes

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

Next Time I will try to Best Speak English Via Google Translator , I need only modify the script that't it. 

Likes

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
    • 1
    • 2