Copy link to clipboard
Copied
Hi,
I am trying to create a script which puts a rectangle behind a piece of selected text. I have done this part, but is there a way to style this box from within the script?
I would like for it to have some dropshadow and round it's corners but I cannot find any information regarding doing this.
Many thanks
Hi,
You can create a rounded rectangle natively with this code:
app.activeDocument.pathItems.roundedRectangle (0, 0, 40, 8, 4, 4);
//app.activeDocument.pathItems.roundedRectangle (top [x coordinate], left [y coordinate], rectangle width, rectangle height, horizontal Radius, vertical Radius)
To "Drop shadow", you can use a graphicStyles:
var style = doc.graphicStyles[1];
style.applyTo(app.activeDocument.selection[0]);
Sample code:
...var doc = app.activeDocument;
var style = doc.graphicStyles[1];
var rndR
Copy link to clipboard
Copied
Hi,
You can create a rounded rectangle natively with this code:
app.activeDocument.pathItems.roundedRectangle (0, 0, 40, 8, 4, 4);
//app.activeDocument.pathItems.roundedRectangle (top [x coordinate], left [y coordinate], rectangle width, rectangle height, horizontal Radius, vertical Radius)
To "Drop shadow", you can use a graphicStyles:
var style = doc.graphicStyles[1];
style.applyTo(app.activeDocument.selection[0]);
Sample code:
var doc = app.activeDocument;
var style = doc.graphicStyles[1];
var rndRect = doc.pathItems.roundedRectangle (0, 0, 40, 8, 4, 4);
//Apply Graphic Style to rectangle
style.applyTo(rndRect);
Copy link to clipboard
Copied
Amazing stuff, this is so helpful!
Is there reference for the roundedRectangle anywhere? I just couldn't find any so either I'm blind, stupid or possibly both?
Also, in regards to the Drop Shadow, is there a way to change the attributes? i.e. opacity, blur, offset.
Cheers!!
Copy link to clipboard
Copied
… maybe only blind.
Sorry, that was only a joke.
One place on your computer is the OMV in ESTK (if you already use ExtendScript Toolkit)
Copy link to clipboard
Copied
Unfortunately, I have not been able to use the ESTK as the IT systems I am using at work doesn't allow me to use it (Ridiculous, I know) so I have been writing it all in Visual Studio Code.
Would've been a lot less hassle with that information though!
Copy link to clipboard
Copied
There are good online libraries (but mostly for [JS] - normaly you can adapt the commands)
Here is a good one by Gregor Fellenz:
https://www.indesignjs.de/extendscriptAPI/illustrator-latest/#about.html
Find more inspiration, events, and resources on the new Adobe Community
Explore Now