How to get Links scaling in illustrator using JavaScript

Community Beginner ,
Dec 24, 2020

Copy link to clipboard

Copied

Hi,

 

How to get links scaling X-value and Y-Value in illustator using javascript.

 

Thanks

Hi, here's an example of getting scale and rotation of linked (or embedded) item:

 

var item = app.activeDocument.selection[0];
if (item.typename == 'PlacedItem' || item.typename == 'RasterItem') {
    var m = item.matrix;
    var rotatedAmount = asDegrees(Math.atan2(m.mValueB, m.mValueA));
    //rotation goes the other way for placed items!
    if (item.typename == 'PlacedItem') rotatedAmount = -rotatedAmount;
    var scaledAmount = [m.mValueA * 100, m.mValueD * 100];
    alert(item.typename
        + '\nscaleX = ' + scaledAmount[0]
        + '\nscaleY = ' + scaledAmount[1]
        + '\nrotation = ' + rotatedAmount
    );
}
function asDegrees(radians) { return radians * 57.2957795 }
TOPICS
Scripting

Views

62

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

How to get Links scaling in illustrator using JavaScript

Community Beginner ,
Dec 24, 2020

Copy link to clipboard

Copied

Hi,

 

How to get links scaling X-value and Y-Value in illustator using javascript.

 

Thanks

Hi, here's an example of getting scale and rotation of linked (or embedded) item:

 

var item = app.activeDocument.selection[0];
if (item.typename == 'PlacedItem' || item.typename == 'RasterItem') {
    var m = item.matrix;
    var rotatedAmount = asDegrees(Math.atan2(m.mValueB, m.mValueA));
    //rotation goes the other way for placed items!
    if (item.typename == 'PlacedItem') rotatedAmount = -rotatedAmount;
    var scaledAmount = [m.mValueA * 100, m.mValueD * 100];
    alert(item.typename
        + '\nscaleX = ' + scaledAmount[0]
        + '\nscaleY = ' + scaledAmount[1]
        + '\nrotation = ' + rotatedAmount
    );
}
function asDegrees(radians) { return radians * 57.2957795 }
TOPICS
Scripting

Views

63

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
Dec 24, 2020 0
Engaged ,
Dec 24, 2020

Copy link to clipboard

Copied

Hi, here's an example of getting scale and rotation of linked (or embedded) item:

 

var item = app.activeDocument.selection[0];
if (item.typename == 'PlacedItem' || item.typename == 'RasterItem') {
    var m = item.matrix;
    var rotatedAmount = asDegrees(Math.atan2(m.mValueB, m.mValueA));
    //rotation goes the other way for placed items!
    if (item.typename == 'PlacedItem') rotatedAmount = -rotatedAmount;
    var scaledAmount = [m.mValueA * 100, m.mValueD * 100];
    alert(item.typename
        + '\nscaleX = ' + scaledAmount[0]
        + '\nscaleY = ' + scaledAmount[1]
        + '\nrotation = ' + rotatedAmount
    );
}
function asDegrees(radians) { return radians * 57.2957795 }

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...
Dec 24, 2020 3
New Here ,
Dec 25, 2020

Copy link to clipboard

Copied

Hello! m1b Check if there is a zoom in the connection diagram, and if there is a zoomed-in or enlarged link diagram, select it. How to script this? Thank you

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...
Dec 25, 2020 0
m1b LATEST
Engaged ,
Dec 25, 2020

Copy link to clipboard

Copied

No quite sure yet what you mean. You want script to select a linked image (PlacedItem) that has a scale greater than 100?

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...
Dec 25, 2020 0
Resources