1

我有一个执行以下操作的脚本:

    var document = app.documents.item(0);
    var layer = document.layers.itemByName("Normal");
    var allTextFrames = toArray(layer.textFrames);
    var moved = selectWhere("moved", "label", allTextFrames)[0];
    var notMoved = selectWhere("notMoved", "label", allTextFrames)[0];
    var instance = selectWhere("instance", "label", allTextFrames)[0];
    $.writeln("Moved          : " + moved.geometricBounds.join(", "));
    $.writeln("Moved overr: " + moved.overriddenMasterPageItem.geometricBounds.join(", "));
    $.writeln("notMoved          : " + notMoved.geometricBounds.join(", "));
    $.writeln("notMoved overr: " + notMoved.overriddenMasterPageItem.geometricBounds.join(", "));



    var overr = moved.overriddenMasterPageItem;
    moved.geometricBounds = [moved.overriddenMasterPageItem.geometricBounds[0] 
                                            ,moved.overriddenMasterPageItem.geometricBounds[1]
                                            ,moved.overriddenMasterPageItem.geometricBounds[2]
                                            ,moved.overriddenMasterPageItem.geometricBounds[3]];
    moved.visibleBounds =      [moved.overriddenMasterPageItem.visibleBounds[0] 
                                            ,moved.overriddenMasterPageItem.visibleBounds[1]
                                            ,moved.overriddenMasterPageItem.visibleBounds[2]
                                            ,moved.overriddenMasterPageItem.visibleBounds[3]];

但是,如果我更改母版页中的文本框架,它不会更新“移动”的文本框架......

例如,pageItem 有一个属性,当设置为“-1”时,它将使用母版页值。我一直在寻找类似的东西,但位置和大小。

fillTint number 只读 PageItem 的填充颜色中使用的色调百分比。(要指定色调百分比,请使用 0 到 100 范围内的数字;要使用继承或覆盖的值,请使用 -1。) src:http: //jongware.mit.edu/iccs5_html_3.0.3d/iccs5/ pc_PageItem.html

4

1 回答 1

0

我不会标记为 anwser,因为有时不起作用;

这是将删除文本框架并恢复的脚本。然后它为它提供旧文本框的数据。它还将文本框链接到上一个和下一个文本框。

如何使用:

  • 创建脚本并粘贴以下内容
  • 选择移动的文本框并运行脚本。
  • 完毕!!!

    #target "indesign"
    #targetengine "mySessionX"
    var SCRIPT_NAME = "Restore moved text frames";
    try{
    app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, SCRIPT_NAME);
    }catch(e){
        alert(e);
    }
    
    function main(){
        removeOverrides(app.selection[0]);
    }
    
    function removeOverrides(textFrame){
        if(textFrame.constructor.name != "TextFrame"){
            throw new Error("No text frame selected");
        }
        // save data
        var contents = textFrame.contents;
        var contentType = textFrame.contentType;
        var nextTextFrame = textFrame.nextTextFrame;
        var previousTextFrame = textFrame.previousTextFrame;
        var masterPageTextFrame = textFrame.overriddenMasterPageItem;
        var page = textFrame.parentPage;
        if(nextTextFrame){
            nextTextFrame.previousTextFrame = null;
        }
        if(previousTextFrame){
            previousTextFrame.nextTextFrame = null;
        }
    
        // remove overrides
        textFrame.removeOverride();
    
        // restore state
        var newTextFrame = masterPageTextFrame.override(page);
        newTextFrame.contents = contents;
        newTextFrame.contentType = contentType;
    
        // update right and left
        if(nextTextFrame){
            nextTextFrame.previousTextFrame = newTextFrame
        }
        if(previousTextFrame){
            previousTextFrame.nextTextFrame = newTextFrame
        }
    
    
        newTextFrame.recompose();
        alert("Restored");
    }
    
于 2013-04-18T13:59:39.000 回答