0

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]);
Sterling Archer
  • 22,070
  • 18
  • 81
  • 118
Bob Haslett
  • 961
  • 1
  • 10
  • 31

1 Answers1

2

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]];
Jongware
  • 22,200
  • 8
  • 54
  • 100