我有一个执行以下操作的脚本:
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有一个属性,当when设置为“-1”时,它将使用母版页值。我正在寻找类似的东西,但是位置和大小。
fillTint number readonly在PageItem的填充颜色中使用的色调百分比。 (要指定色调百分比,请使用0到100范围内的数字;要使用继承或覆盖的值,请使用-1。) src:http://jongware.mit.edu/iccs5_html_3.0.3d/iccs5/pc_PageItem.html
答案 0 :(得分: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");
}