Skip to main content
OMOTI
Inspiring
March 1, 2018
Question

The initial value of mValueTX and mValueTY

  • March 1, 2018
  • 2 replies
  • 1301 views

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

This topic has been closed for replies.

2 replies

OMOTI
OMOTIAuthor
Inspiring
March 6, 2018

thanks for your help.

OMOTI
OMOTIAuthor
Inspiring
April 11, 2018

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

Correctly here.

return new Rect(

     left,

     top,

     left + LARGEST_SIZE,

     top - LARGEST_SIZE

);

OMOTI
OMOTIAuthor
Inspiring
March 2, 2018

CarlosCanto
Community Expert
Community Expert
March 4, 2018

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

OMOTI
OMOTIAuthor
Inspiring
March 5, 2018

Hi CarlosCanto, thank you for testing.

Which is your OS, Windows or macOS?

I wish I could know the Windows information.