: Text variables of frame's properties in Adobe Indesign How do I create text variables of a frame's width and height then insert them as the text? Or is it possible to do that?
How do I create text variables of a frame's width and height then insert them as the text? Or is it possible to do that?
More posts by @Alves566
1 Comments
Sorted by latest first Latest Oldest Best
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");
}
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.