#target indesign
function getSize (item) {
if (item.hasOwnProperty('geometricBounds')) { // geometricBounds or visibleBounds
var gb = item.geometricBounds;
var h = gb[2] - gb[0];
var w = gb[3] - gb[1];
return {height: h, width: w};
} else {
return null;
}
}
function main () {
if (!app.documents.length) {
return false;
}
var doc = app.activeDocument;
var sizeH = 2.8 // set height value
doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
var rectangles = doc.rectangles.everyItem().getElements();
var rem = [];
for (var i = 0; i < rectangles.length; i++) {
var size = getSize(rectangles[i]);
if (size && Math.abs(size.height - sizeH) < 0.001) { // 0.001 precision
rem.push(rectangles[i]);
}
}
rem.reverse();
for (var i = 0; i < rem.length; i++) {
rem[i].remove();
}
}
main();