Script for count dimenstion
Hello 🙂 Iam trying to make a script which will count dimension of selected object and it will make it bigger 8mm in width and in height. I was tying to use chatgpt for help and i tried a lot of version but its still not counting correctly and always making me new object bigger 2.8 mm instea of 8... what can be wrong?
// Check if there is an active document
if (app.documents.length > 0) {
var doc = app.activeDocument;
var sel = doc.selection;
// Check if there is at least one object selected
if (sel.length > 0) {
var selectedObject = sel[0]; // Get the first selected object
// Get the dimensions of the selected object
var bounds = selectedObject.visibleBounds;
var width = bounds[2] - bounds[0];
var height = bounds[1] - bounds[3];
// Calculate new dimensions
var newWidth = width + 8; // Increase width by 8 mm
var newHeight = height + 8; // Increase height by 8 mm
// Resize the selected object
selectedObject.width = newWidth;
selectedObject.height = newHeight;
} else {
alert("Please select an object.");
}
} else {
alert("Please open a document.");
}
