Get Actual Bounding Box Size in Illustrator with Script Function

Illustrator中,可以通过脚本函数快速得到对象的实际外框大小。以下是一个示例函数:

function getBoundingBoxSize(item) {
    if (item && item.visible) {
        var bounds = item.geometricBounds; // 获取几何边界
        var width = bounds[2] - bounds[0]; // 计算宽度
        var height = bounds[1] - bounds[3]; // 计算高度
        return {width: width, height: height};
    }
    return null;
}

使用这个函数,您可以轻松获取所选对象的外框大小

jsx 文件大小:2.93KB