Mobile app version of vmapp.org
Login or Join

Login to follow query

More posts by @Alves566

1 Comments

Sorted by latest first Latest Oldest Best

 

@Pierce403

You can try this rather basic script.
Returned values are based on object bounds, meaning that if you run it on a rotated object, returned values will be different than the ones in your Transform panel.
Also, it includes strokes. If you want to exclude them, just change line 5 visibleBounds to geometricBounds;

if (app.documents.length > 0) {
var myDocument = app.documents[0];
var mySelection = myDocument.selection[0];
var myPage = mySelection.parentPage;
var VB = mySelection.visibleBounds;
var mySelectionHeight = VB[2] - VB[0];
var mySelectionWidth = VB[3] - VB[1];
var myTextFrame = myPage.textFrames.add({
geometricBounds: [VB[0], VB[1], VB[2], VB[3]]
});

if (app.selection.length == 0) {
alert("Select something");
} else {
myTextFrame.contents = "Height = " + mySelectionHeight + " rWidth = " + mySelectionWidth;
myTextFrame.fit(FitOptions.FRAME_TO_CONTENT);
}

} else {
alert("Open a document");
}

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme