Copy link to clipboard
Copied
Hello everyone! I'm working with multiple text layers, and my task is to create an ellipse shape below a text layer, which the edges of the ellipse are a fixed distance from the longest points of the text. For example:
The distance varies depending on each job requirement, sometimes it will be 150px, 200px,... so my idea is to put the text layer on a smart object, then enlarge the canvas to double the required number of given pixels, or give that text a stroke equal to that number of pixels then convert to smart object.
The next problem is: how to create an ellipse that fits the canvas inside the smart object? Is there any action or script that does that? I usually use the shape tool to drag from the top left to the right end of the canvas, but because I did it manually, it will make a bit deviation, and I can't type the size for thousands of ellipse for each text layers due to my deadlines.
Hope you guys could give me a solution. Thank you very much!
// 2023, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
createEllipse ([0,0,activeDocument.width,activeDocument.height], 255, 255, 255);
app.preferences.rulerUnits = originalRulerUnits;
};
//////////////////
function createEllipse (theBounds, theR, theG, theB) {
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
var idmake = stringIDToTypeID( "make" );
var desc1
...
Copy link to clipboard
Copied
// 2023, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
createEllipse ([0,0,activeDocument.width,activeDocument.height], 255, 255, 255);
app.preferences.rulerUnits = originalRulerUnits;
};
//////////////////
function createEllipse (theBounds, theR, theG, theB) {
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
var idmake = stringIDToTypeID( "make" );
var desc15 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref4 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
ref4.putClass( idcontentLayer );
desc15.putReference( idnull, ref4 );
var idusing = stringIDToTypeID( "using" );
var desc16 = new ActionDescriptor();
var idtype = stringIDToTypeID( "type" );
var desc17 = new ActionDescriptor();
var idcolor = stringIDToTypeID( "color" );
var desc18 = new ActionDescriptor();
var idred = stringIDToTypeID( "red" );
desc18.putDouble( idred, theR );
var idgrain = stringIDToTypeID( "grain" );
desc18.putDouble( idgrain, theG );
var idblue = stringIDToTypeID( "blue" );
desc18.putDouble( idblue, theB );
var idRGBColor = stringIDToTypeID( "RGBColor" );
desc17.putObject( idcolor, idRGBColor, desc18 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc16.putObject( idtype, idsolidColorLayer, desc17 );
var idshape = stringIDToTypeID( "shape" );
var desc19 = new ActionDescriptor();
var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" );
desc19.putInteger( idunitValueQuadVersion, 1 );
var idtop = stringIDToTypeID( "top" );
desc19.putUnitDouble( idtop, idpixelsUnit, theBounds[1] );
var idleft = stringIDToTypeID( "left" );
desc19.putUnitDouble( idleft, idpixelsUnit, theBounds[0] );
var idbottom = stringIDToTypeID( "bottom" );
desc19.putUnitDouble( idbottom, idpixelsUnit, theBounds[3] );
var idright = stringIDToTypeID( "right" );
desc19.putUnitDouble( idright, idpixelsUnit, theBounds[2] );
var idellipse = stringIDToTypeID( "ellipse" );
desc16.putObject( idshape, idellipse, desc19 );
var idcontentLayer = stringIDToTypeID( "contentLayer" );
desc15.putObject( idusing, idcontentLayer, desc16 );
var idlayerID = stringIDToTypeID( "layerID" );
desc15.putInteger( idlayerID, 3 );
executeAction( idmake, desc15, DialogModes.NO );
};
Copy link to clipboard
Copied
Thank you!!! Thank you so much, this script save me a whole life!!! Many thanks!!
Copy link to clipboard
Copied
You’re welcome.
Copy link to clipboard
Copied