When override with a script a pageItem on parent page with resizing history with a script, the coordinates will be shifted.
Version: any (It can be easily checked in the version with the page tool.)
Step to reproduce the issues
Open the document,
add a new parentSpread with different size,
resize a added parentSpread to document origin with pageTool,
create some objects on a added parentSpread,
apply parentPage to document pages,
and override them with script,
like this.
var doc = app.activeDocument;
for(var p = 0; p < doc.pages.length; p++){
var pg = doc.pages[p];
var ms = pg.appliedMaster;
if(!ms)continue;
var mi = ms.pageItems;
for(var i = mi.length-1; i >= 0; i--){
var itm = mi[i];
try{
itm.override(pg);
}catch(e){}
}
}Expected result
Parent objects are overriden with keeping coordinates.Actual result
Half of the resizing amount of the parentPage, the coordinates are offset and overridenNote
The problem occurs only when the script is executed for the first time, and after the second time, it is processed normally. I am currently working by avoiding problems by applying the parent page only to the temporary new page and running the script, deleting the temporary page and applying the parent page to the entire document, and running the script again.
It’s so harder.
<に ほ ん ご>
題:
リサイズ履歴のある親ページのページアイテムをスクリプトでオーバーライドすると座標がずれる
バージョン:
どれでも(ページツールを有するバージョンで容易に確認できる)
再現までの手順:
ドキュメントを開き、新規親ページを作成。このときページサイズを大きくするなど、元とは異なる値に設定しておく。
ページツールで親ページを元のドキュメントのページサイズに変更。
その親ページ上に何かオブジェクトを作成(親ページアイテムとなる)。
ドキュメントページにその親ページを適用。
スクリプトを用いて親ページアイテムをオーバーライドする。
期待される結果:
親ページアイテムは元の座標にオーバーライドされる。
実際の結果:
親ページのリサイズ前後の寸法の差分の半分だけオブジェクトがずれてオーバーライドされる。
おまけ:
スクリプト実行で異常な結果が出るのは初回実行時のみで、2回目以降は正常な動作をする。
そのため、私めは現在、ダミーの新規ページだけに親ページを適用し、スクリプトを実行して、ダミーページを削除、あらためて全ページに親ページを適用し、それから再度スクリプトをすることで問題を回避している。
たいへんである。