Copy link to clipboard
Copied
The script that you see creates a cyan guide at the left edge of the layer (or document).
Cyan guides are always visible, and light blue hides when switching artboards.
I would like to change the script so that it creates a light blue guide instead of cyan. How to do it?
Cyan canvas guides → Light blue artboard guides
//Select Active Layer
var docRef = app.activeDocument,
activeLayer = docRef.activeLayer;
activeLayerCoordinates = activeLayer.bounds;
function traceGuide(guide) {
var orientation = '';
if(guide === 0 || guide === 2) {
orientation = Direction.VERTICAL;
} else if(guide === 1 || guide === 3) {
orientation = Direction.HORIZONTAL;
}
docRef.guides.add(orientation,activeLayerCoordinates[guide]);
}
// Trace top guide
traceGuide(0);
Hi alextul,
try this
...var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putUnitDouble( charIDToTypeID('Pstn'), charIDToTypeID('#Pxl'), 178 ); // position
desc2.putEnumerated( charIDToTypeID('Ornt'), charIDToTypeID('Ornt'), charIDToTypeID('Vrtc') ); // vertical //or horizontal --> Hrzn
desc2.putEnumerated( charIDToTypeID('Knd '), charIDToTypeID('Knd '), charIDToTypeID('Dcmn') );
var ref1 = new ActionReference();
ref1.putIdentifier( charI
Copy link to clipboard
Copied
//Select Active Layer
var docRef = app.activeDocument,
activeLayer = docRef.activeLayer;
activeLayerCoordinates = activeLayer.bounds;
function traceGuide(guide) {
var orientation = '';
if (guide === 0 || guide === 2) {
orientation = Direction.VERTICAL;
} else if (guide === 1 || guide === 3) {
orientation = Direction.HORIZONTAL;
}
docRef.guides.add(orientation, activeLayerCoordinates[guide]);
}
// Trace top guide
traceGuide(0);
// Guid Blue
var idsetd = charIDToTypeID("setd");
var desc19 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref4 = new ActionReference();
var idPrpr = charIDToTypeID("Prpr");
var idGdPr = charIDToTypeID("GdPr");
ref4.putProperty(idPrpr, idGdPr);
var idcapp = charIDToTypeID("capp");
var idOrdn = charIDToTypeID("Ordn");
var idTrgt = charIDToTypeID("Trgt");
ref4.putEnumerated(idcapp, idOrdn, idTrgt);
desc19.putReference(idnull, ref4);
var idT = charIDToTypeID("T ");
var desc20 = new ActionDescriptor();
var idGdsC = charIDToTypeID("GdsC");
var idGdGr = charIDToTypeID("GdGr");
var idLgtB = charIDToTypeID("LgtB");
desc20.putEnumerated(idGdsC, idGdGr, idLgtB);
var idGdPr = charIDToTypeID("GdPr");
desc19.putObject(idT, idGdPr, desc20);
executeAction(idsetd, desc19, DialogModes.NO);
Copy link to clipboard
Copied
I can change the color of the guides in the settings without scripts.
I need the script to create artboard guides instead of canvas guides. This means that they must be hidden when switching artboards.
Copy link to clipboard
Copied
Help me please.
Copy link to clipboard
Copied
Hi alextul,
try this
var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putUnitDouble( charIDToTypeID('Pstn'), charIDToTypeID('#Pxl'), 178 ); // position
desc2.putEnumerated( charIDToTypeID('Ornt'), charIDToTypeID('Ornt'), charIDToTypeID('Vrtc') ); // vertical //or horizontal --> Hrzn
desc2.putEnumerated( charIDToTypeID('Knd '), charIDToTypeID('Knd '), charIDToTypeID('Dcmn') );
var ref1 = new ActionReference();
ref1.putIdentifier( charIDToTypeID('Dcmn'), 211 );
ref1.putIndex( charIDToTypeID('Gd '), 1 );
desc2.putReference( charIDToTypeID('null'), ref1 );
desc1.putObject( charIDToTypeID('Nw '), charIDToTypeID('Gd '), desc2 );
var ref2 = new ActionReference();
ref2.putClass( charIDToTypeID('Gd ') );
desc1.putReference( charIDToTypeID('null'), ref2 );
desc1.putEnumerated( stringIDToTypeID('guideTarget'), stringIDToTypeID('guideTarget'), stringIDToTypeID('guideTargetSelectedArtboard') );
executeAction( charIDToTypeID('Mk '), desc1, DialogModes.NO );
(an artboard should exists in your document, otherwise a "normal" guide will be created)
Have fun
Copy link to clipboard
Copied
Hi pixxxel schubser, your script creates a guide at a distance of 178 pixels from the border of the artboard. Can I somehow make the guide stick to the layer (or the artboard, if there are no layers) and to the pixel selection area?
And if possible, let the script create four guides at each edge of the layer (artboard) or the pixel selection area, as well as two guides along the center (horizontal and vertical).
Copy link to clipboard
Copied
Read the selection.bounds[array] and use the values.
This also should helps you on your way: Re: How to get artboard properties in photoshop CC 2015?
Copy link to clipboard
Copied
Many thanks!
Copy link to clipboard
Copied
('#Pxl'), 178 ) how to change inches plz sir