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);
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi OMOTI, that seems to be correct. It works, thanks for sharing!!
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.
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
Copy link to clipboard
Copied
thanks for your help.
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
);