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

need a script to calculate raduis and create frame around shape

Explorer ,
Nov 21, 2020 Nov 21, 2020

Copy link to clipboard

Copied

I need a script that calculates the radius of a rectangle on the side, and creates a dotted pink square around a shape. Attached files

 

https://www.dropbox.com/sh/gcxlylnbhy5vop3/AAATBuzwS1EFLzLUBPyE999da?dl=0

 

 

TOPICS
Scripting

Views

826

Translate

Translate

Report

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
Adobe
Community Expert ,
Nov 21, 2020 Nov 21, 2020

Copy link to clipboard

Copied

Do you really need a script for that? I don't think.

 

dashed_stroke.png

Save a graphic style and apply it to all objects.

 

dashed_stroke_01.png

If that works for you

have fun

😉

 

Votes

Translate

Translate

Report

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
Explorer ,
Nov 21, 2020 Nov 21, 2020

Copy link to clipboard

Copied

I asked to expand an existing script that I have attached because I do this thing many times a day. Nor did you refer to the fact that I need to calculate the radius. I would be grateful for the extension of the attached code.

Votes

Translate

Translate

Report

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 ,
Nov 21, 2020 Nov 21, 2020

Copy link to clipboard

Copied

I would just ask the person who wrote the original script.

Votes

Translate

Translate

Report

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
Guide ,
Nov 21, 2020 Nov 21, 2020

Copy link to clipboard

Copied

By "radius" of a rectangle, do you mean diagonal of a rectangle?  I'm not sure where the r. 3528 in your attached file comes from. 

Votes

Translate

Translate

Report

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
Advocate ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

He was referring to the corner radius. Only he just made a mistake in the decimal place > instead of "r. 3528" he mean "r 3.528"

Votes

Translate

Translate

Report

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 ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Hi @Tom Winkelmann,

I'm the same opinion.

-----------------------------------------------------------------

 

Hi @aviel222,

1)

What about your other threads? Are they resolved?

For example:

 

Script correction to measure width and height together 

-----------------------------------------------------------------

 

2)

@aviel222 wrote: "I asked to expand an existing script … Nor did you refer to the fact that I need to calculate the radius …."

We are users like you. And we want to help you!

"Don't bite the hand that feeds you."

 

I gave you a partial solution to the outline (no scripting) that doesn't take any time - once the graphic style has been created. We don't know anything about your project. I am so sorry this was not acceptable to you!

 

Here is a script snippet that does the same - it creates a dashed stroke for the selected path item:

// pathItem_dashed_Stroke.jsx
// select one pathItem before running this script snippet
// regards pixxxelschubser

var aDoc = app.activeDocument;
var aSel = aDoc.selection[0];
aSel.stroked = true;
// swatch with name "CMYK Magenta" should already exists in your document
aSel.strokeColor = aDoc.swatches.getByName("CMYK Magenta").color;
aSel.strokeDashes = [2.8346457];
aSel.strokeWidth = 2.8346457;

 

There is no error management and you should build it into the other script yourself.

-----------------------------------------------------------------

 

3)

I will not make any changes to the script without the permission of the author! Sorry.

In addition, "your" script shown is an outdated variant.

-----------------------------------------------------------------

 

4)

The calculation of rounding depends on so many factors in your documents and objects that it is impossible to even remotely predict how much time it will take. So I cannot help you on this point.

Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Thank you!!!

Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Why is it so complicated to calculate the radius of the corners of the rectangle?
(diagonal of a rectangle)

I do not mind paying you for it
But depends on how many.

Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

"Round corners" 

Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

I just meant "round corners"

Votes

Translate

Translate

Report

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
Guide ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Is this the radius we're talking about?  If so, it would seem that this is easy to calculate. 

 

 Untitled.png

Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Yes!!! Exactly 

Votes

Translate

Translate

Report

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 ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Hi @femkeblanco 

please identify the roundness and if so the radius of each corner.

 

aa9d.png

Votes

Translate

Translate

Report

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
Guide ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Hi @pixxxelschubser.  I take your point about roundness.  But since we seem to be talking about a "radius", I presume we are talking about a (all symmetric) circle with a (single) radius. 

Votes

Translate

Translate

Report

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 ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Experience shows that one can very rarely rely on such assumptions. Especially if someone asks without an exact detailed description: Can someone write a script for me.

Votes

Translate

Translate

Report

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
Guide ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

I agree with your point:  detailed descriptions are critical. 

Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Friends
There was a misunderstanding
I'm attaching a screenshot to what I needScreen Shot 2020-11-22 at 18.37.43.png

Votes

Translate

Translate

Report

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 ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

I'm sorry to have to laugh.

 

This is the worst case scenario. We don't have access to the Appearance panel and assigned effects.

Votes

Translate

Translate

Report

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 ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Ok. The long way is mostly possible:

  • duplicate you pathItem ( = helpers object)
  • expand helpers object
  • read the values of each pathPoint
  • calculate the radius of each corner
  • write the values of your radii into document
  • remove the helpers object

Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

pixxxelschubser

I did not understand anything.
I'm asking if you can write me a script
Thanks 

Votes

Translate

Translate

Report

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 ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Unfortunately not.
I'm just showing you how other scripters should go about it to get the value for the radii.

 

Don't forget: I previously posted the less complex script snippet for the dashed outline here in the thread. Have you tried it meanwhile?

 

 

And again:

@pixxxelschubser wrote: "…Hi @aviel222,

1)

What about your other threads? Are they resolved?

For example:

 

Script correction to measure width and height together"

Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

Yes, it works great !!!
Thanks.

Votes

Translate

Translate

Report

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
Explorer ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

So maybe someone else will help me about the round corners?

Votes

Translate

Translate

Report

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
Guide ,
Nov 22, 2020 Nov 22, 2020

Copy link to clipboard

Copied

// select round-cornered rectangle
var points = app.selection[0].pathPoints;
var x1 = points[4].anchor[0], x2 = points[5].anchor[0];
var y1 = points[4].anchor[1], y2 = points[5].anchor[1];
var rect1 = app.activeDocument.pathItems.rectangle(y1 + 20, x2 - 30, 20, 20);
var text2 = app.activeDocument.textFrames.areaText(rect1);
text2.contents = Math.abs(x1 - x2);

Note that this has to be a truly round-cornered rectangle and not an effect.  An effect is an appearance attribute, i.e. the rectangle appears to be round-cornered, but is not truly so.  If you used an effect, you need to expand the appearance first (Object > Expand Appearance). 

Votes

Translate

Translate

Report

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