문제

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