3

我需要选择大小介于两个值之间的所有文本对象,例如 12 和 14pt(包括 12.1、12.2 等)。这是可能吗?

4

1 回答 1

6

这似乎是脚本的候选者。试试这个:

function selectTextWhosePointSizeIs ( minPointSize, maxPointSize )
{
    var doc, tfs, i = 0, n = 0, selectionArray = [];

    if ( !app.documents.length ) { return; }

    doc = app.activeDocument;
    tfs = doc.textFrames;
    n = tfs.length;

    if ( !n ){ return; }

    if ( isNaN ( minPointSize ) )
    {
        alert(minPointSize + " is not a valid number" );
        return;
    }
    else if ( isNaN ( maxPointSize ) )
    {
        alert(maxPointSize + " is not a valid number" );
        return;
    }
    else if ( minPointSize > maxPointSize )
    {
        alert(minPointSize + " can't be greater than "+ maxPointSize);
        return;
    }

    for ( i = 0 ; i < n ; i++ )
    {
        if ( tfs[i].textRange.size >= minPointSize && tfs[i].textRange.size <= maxPointSize )
        {
            selectionArray [ selectionArray.length ] = tfs[i];
        }
    }

    if ( selectionArray.length )
    {
        app.selection = selectionArray;
    }
    else
    {
        alert("Nothing found in this range.");
    }
}

selectTextWhosePointSizeIs ( 12, 14 );

希望能帮助到你,

洛伊克

于 2012-06-23T21:06:37.227 回答