Determine a numeric value between two tabs in the center of the document. Part II
Part 1: https://forums.adobe.com/thread/2318841
My idea now is to modify the function of the checkbox of this script that gained functionality thanks to our friend SuperMerlin: The purpose of it when enabled, will be to add a more precise final size, increasing only the width of the document, using the same numeric value "cm "Assigned to the two added central tabs.
Example: As shown in the illustration below:

Script:
- #target photoshop;
- app.bringToFront();
- var dial = new Window ("dialog", "My Dialog", undefined);
- dial.orientation = "column";
- dial.alignChildren = "fill";
- dial.margins = 20;
- var dPanel = dial.add ("panel", undefined, "Document Finished Size");
- dPanel.orientation = "column";
- dPanel.alignChildren = "left";
- dPanel.margins = 15;
- var aLevels = dPanel.add ("checkbox", undefined, "Add Finished Size");
- var dGroup = dial.add ("group", undefined);
- dGroup.orientation = "row";
- dGroup.alignChildren = "left";
- var st = dGroup.add ("statictext", undefined, "Add Center Guides:");
- var nField = dGroup.add ("edittext", undefined, "1");
- nField.characters = 4;
- var un = dGroup.add ("statictext", undefined, "Centimeters");
- var gButtons = dial.add ("group", undefined);
- gButtons.orientation = "row";
- gButtons.alignChildren = ["right", "right"];
- var canc = gButtons.add ("button", undefined, "Cancel", {name:"cancel"});
- var exe = gButtons.add ("button", undefined, "To Apply", {name:"ok"});
- exe.onClick = function(){
- dial.close(0);
- var doc = app.activeDocument;
- app.displayDialogs = DialogModes.NO;
- var strtRulerUnits = app.preferences.rulerUnits;
- var strtTypeUnits = app.preferences.typeUnits;
- app.preferences.rulerUnits = Units.PIXELS;
- app.preferences.typeUnits = TypeUnits.PIXELS;
- var Res = doc.resolution;
- if(aLevels.value){
- //code goes here for "Add Finished Size"
- //No idea what you mean.
- }
- var cm = Res/2.54;
- var Width = doc.width;
- var selectedCM = Number( nField.text.toString().replace(/,/g,'.'));
- var leftGuide = (Width/2) - (cm * selectedCM/2);
- var rightGuide = (Width/2) + (cm * selectedCM/2);
- guideLine(leftGuide,'Vrtc','#Pxl');
- guideLine(rightGuide,'Vrtc','#Pxl');
- app.preferences.rulerUnits = strtRulerUnits;
- app.preferences.typeUnits = strtTypeUnits;
- }
- if(documents.length) dial.show();
- function guideLine(position, type,unit) {
- //unit '#Pxl' pixel '#Rlt' =Relative to 72PPI '#Prc' = percent
- // types: 'Vrtc' & 'Hrzn'
- var desc = new ActionDescriptor();
- var desc2 = new ActionDescriptor();
- desc2.putUnitDouble( charIDToTypeID('Pstn'), charIDToTypeID(unit), position);
- desc2.putEnumerated( charIDToTypeID('Ornt'), charIDToTypeID('Ornt'), charIDToTypeID(type) );
- desc.putObject( charIDToTypeID('Nw '), charIDToTypeID('Gd '), desc2 );
- executeAction( charIDToTypeID('Mk '), desc, DialogModes.NO );
- };
Abierto to all.![]()