質問

Could anyone tell me what I'm doing wrong. I would like to change the x coordinate of all the items on an active document so that they are whole numbers. I can loop through and find the items and return their current x value. I can then calculate a new value, but when I apply it (third line of code) nothing seems to happen, its x coordinate remains the same. Here is my code, any help appreciated, thanks

$.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]);
役に立ちましたか?

解決

position is the correct item, but it's a special array; you cannot change only one element of it. You need to set both x and y in one single operation:

currentItem.position = [round, currentItem.position[1]];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top