Highlighted

The initial value of mValueTX and mValueTY

Contributor ,
Mar 01, 2018

Copy link to clipboard

Copied

Hello.

Does the initial values of mValueTX and mValueTY of the object just generated refer the upper left coordinates of the document's largest area? For example, TextFrameItem and PlacedItem.

I want to get the coordinates of the document's largest area easily. Do you have any sugesstions?

I referred to here.

How to get bounds of largest possible document area?

This script worked fine on Illustrator CS6, CC2015, CC2017, CC2018 (for mac).

Is this correct?

function getLargestBounds() {

    var tempLayer,

        tempText,

        left,

        top,

        LARGEST_SIZE = 16383;

    if (!app.documents.length) {

        return;

    }

    tempLayer = app.activeDocument.layers.add();

    tempText = tempLayer.textFrames.add();

    left = tempText.matrix.mValueTX;

    top = tempText.matrix.mValueTY;

    tempLayer.remove();

    return new Rect(

        left,

        top,

        left + LARGEST_SIZE,

        top + LARGEST_SIZE

    );

}

var rect = getLargestBounds();

// cover the whole area.

app.activeDocument.pathItems.rectangle(rect[1], rect[0], 16383, 16383);

TOPICS
Scripting

Views

555

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

The initial value of mValueTX and mValueTY

Contributor ,
Mar 01, 2018

Copy link to clipboard

Copied

Hello.

Does the initial values of mValueTX and mValueTY of the object just generated refer the upper left coordinates of the document's largest area? For example, TextFrameItem and PlacedItem.

I want to get the coordinates of the document's largest area easily. Do you have any sugesstions?

I referred to here.

How to get bounds of largest possible document area?

This script worked fine on Illustrator CS6, CC2015, CC2017, CC2018 (for mac).

Is this correct?

function getLargestBounds() {

    var tempLayer,

        tempText,

        left,

        top,

        LARGEST_SIZE = 16383;

    if (!app.documents.length) {

        return;

    }

    tempLayer = app.activeDocument.layers.add();

    tempText = tempLayer.textFrames.add();

    left = tempText.matrix.mValueTX;

    top = tempText.matrix.mValueTY;

    tempLayer.remove();

    return new Rect(

        left,

        top,

        left + LARGEST_SIZE,

        top + LARGEST_SIZE

    );

}

var rect = getLargestBounds();

// cover the whole area.

app.activeDocument.pathItems.rectangle(rect[1], rect[0], 16383, 16383);

TOPICS
Scripting

Views

556

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
Mar 01, 2018 1
Contributor ,
Mar 02, 2018

Copy link to clipboard

Copied

canvas.png

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...
Mar 02, 2018 1
Adobe Community Professional ,
Mar 04, 2018

Copy link to clipboard

Copied

Hi OMOTI, that seems to be correct. It works, thanks for sharing!!

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...
Mar 04, 2018 1
Contributor ,
Mar 05, 2018

Copy link to clipboard

Copied

Hi CarlosCanto, thank you for testing.

Which is your OS, Windows or macOS?

I wish I could know the Windows information.

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...
Mar 05, 2018 0
Adobe Community Professional ,
Mar 05, 2018

Copy link to clipboard

Copied

Windows 10, CC2018.

I used to use the previous methods mentioned in the link, luckily I've only needed to find the absolute 0,0 on new documents when conditions are know. This method is more reliable.

thanks

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...
Mar 05, 2018 1
Contributor ,
Mar 06, 2018

Copy link to clipboard

Copied

thanks for your help.

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...
Mar 06, 2018 0
OMOTI LATEST
Contributor ,
Apr 11, 2018

Copy link to clipboard

Copied

I'm sorry. The coordinates of the return value were incorrect.

Correctly here.

return new Rect(

     left,

     top,

     left + LARGEST_SIZE,

     top - LARGEST_SIZE

);

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...
Apr 11, 2018 1
Resources