Highlighted

Illustrator JavaScript count area with offset.

New Here ,
Nov 03, 2020

Copy link to clipboard

Copied

Hello,

It is possible to count area with 5 mm. offset?

Example:

  I use this script and want to add a 5 mm offset in the count:

alert (app.activeDocument.selection[0].area);

I want to count irregular square where shape like U form, + offset. Shape 10x10 cm size, with 5x5 cm cut. I want to get a shape area not 75 cm2 but 101cm2.

It is even possible or not? 

Screenshot_1.png

TOPICS
How to, Scripting

Views

119

Likes

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

Illustrator JavaScript count area with offset.

New Here ,
Nov 03, 2020

Copy link to clipboard

Copied

Hello,

It is possible to count area with 5 mm. offset?

Example:

  I use this script and want to add a 5 mm offset in the count:

alert (app.activeDocument.selection[0].area);

I want to count irregular square where shape like U form, + offset. Shape 10x10 cm size, with 5x5 cm cut. I want to get a shape area not 75 cm2 but 101cm2.

It is even possible or not? 

Screenshot_1.png

TOPICS
How to, Scripting

Views

120

Likes

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
Nov 03, 2020 0
Adobe Community Professional ,
Nov 03, 2020

Copy link to clipboard

Copied

obviously you can't get 101 cm2 if you start with 10x10. So, assuming you want to find the size of a rectangle that will give you 101 after substrating a 5x5 area, try this

 

// pseudo code

x2 = 101 cm2 + 25 cm2 = 126 cm2

x = Math.sqrt(x2) = 11.22497 cm

 

Likes

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
Reply
Loading...
Nov 03, 2020 0
Most Valuable Participant ,
Nov 03, 2020

Copy link to clipboard

Copied

Only one question:

10cm ×10cm + offset 0,5cm (all sides)

=

11cm × 11cm

=

121 cm²

 

… or not? Am I wrong?

Likes

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
Reply
Loading...
Nov 03, 2020 0
Adobe Community Professional ,
Nov 03, 2020

Copy link to clipboard

Copied

@pixxxelschubser that's what I thought at first, but I believe that by "offset" he means the 5x5 rectangle

Likes

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
Reply
Loading...
Nov 03, 2020 0
Most Valuable Participant ,
Nov 03, 2020

Copy link to clipboard

Copied

Yes. The description is still not clear for me.

 

And the result of 101cm² is even less clear to me.

Maybe a better screenshot with an offset-object in background an the black object in the foreground will give an enlightenment?

Likes

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
Reply
Loading...
Nov 03, 2020 0
New Here ,
Nov 03, 2020

Copy link to clipboard

Copied

Everything that you all say is correct.

My issue is when, I have shape 100x100 mm with 50x50 cut, and that shape area is 7500 mm2.

Everything is ok if I count with this:

app.activeDocument.pathItems[index].area

 But I need that, area script count with like compensation. Count not original area but bigger shape like that(red dash line):

 

Screenshot_2.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

And then I get that my area is 10100 mm2. I Dont want to add that new one shape just for the count area, it is possible to make with the script?

Likes

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
Reply
Loading...
Nov 03, 2020 0
Engaged ,
Nov 04, 2020

Copy link to clipboard

Copied

It's possible.  But why not simply do "offset path", run your line of code and then undo.  It will take seconds.  Scripting will just emulate this.  

Likes

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
Reply
Loading...
Nov 04, 2020 0
New Here ,
Nov 04, 2020

Copy link to clipboard

Copied

Maybe it's possible, but I need in the same script real area and with „Offset path“, and I have countless different shapes where I mus count that area. That's why I ask it is possible to make that script, and maybe someone knows how?

Likes

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
Reply
Loading...
Nov 04, 2020 0
Resources