Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Is there a way to add Dropshadow and/or rounded corners to a created shape?

Community Beginner ,
Apr 30, 2019 Apr 30, 2019

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

TOPICS
Scripting
1.5K
Translate
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

Contributor , Apr 30, 2019 Apr 30, 2019

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

...
Translate
Adobe
Contributor ,
Apr 30, 2019 Apr 30, 2019

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);

Translate
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
Community Beginner ,
Apr 30, 2019 Apr 30, 2019

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!!

Translate
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
Community Expert ,
May 01, 2019 May 01, 2019

… 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)

OMV_RoundedRectangle.png

Translate
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
Community Beginner ,
May 01, 2019 May 01, 2019

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!

Translate
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
Community Expert ,
May 01, 2019 May 01, 2019
LATEST

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

Translate
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