在illustrator extendscript中更改对象x坐标的值

时间:2014-05-08 17:25:07

标签: javascript adobe-illustrator extendscript

有谁能告诉我我做错了什么。我想更改活动文档上所有项目的x坐标,以便它们是整数。我可以遍历并查找项目并返回其当前的x值。然后我可以计算一个新值,但是当我应用它时(第三行代码)似乎没有发生任何事情,它的x坐标保持不变。这是我的代码,感谢任何帮助,谢谢

$.writeln("Current item x position=", currentItem.position[0]);
round=Math.round(currentItem.position[0]);
currentItem.position[0]=round
$.writeln("Current item x=", round);
$.writeln("New item x position=", currentItem.position[0]);

1 个答案:

答案 0 :(得分:1)

position是正确的项目,但它是一个特殊的数组;你不能只改变它的一个元素。您需要在一次操作中同时设置 x y

currentItem.position = [round, currentItem.position[1]];