Copy link to clipboard
Copied
Hello, hello
I have a problem with property position about pathItem in Illustrator, in Javascript I can write : object.position[0] = newValue and position from object change.
But no with illustrator objects, I can't use pathItem.position[0] = newValue because position from pathItem don't change.
I try a test, I share with you code :
---------
var x = app.activeDocument.activeLayer.pathItems["coucou"]
$.writeln("First value : " + x.position) //Result : First value : 17,-11
x.position[0] = 10
x.position[1] = 20
$.writeln("New value : " + x.position) //Result: New value : 17,-11
---------
Thank you, thank you for your help and sorry for my bad english
that's how it works, position property takes a pair of values. You can't assign each value individually.
try this instead, if you want to change only the x position
var left = 10;
var top = x.position[1];
x.position = [left, top];
Copy link to clipboard
Copied
try this:
var x = app.activeDocument.activeLayer.pathItems["coucou"]
$.writeln("First value : " + x.position) //Result : First value : 17,-11
x.position = [10,20];
$.writeln("New value : " + x.position) //Result: New value : 17,-11
Copy link to clipboard
Copied
Hello, thank you for your answer.
I can do this but I want just modify one value without write all array.
When I write :
---
var x = [1, 2, 3];
x[0] = 10;
$.writeln(x[0]) //Result : 10
---
I want do it with property position without write all array.
It's work for object JavaScript but no for Illustrator object.
Copy link to clipboard
Copied
that's how it works, position property takes a pair of values. You can't assign each value individually.
try this instead, if you want to change only the x position
var left = 10;
var top = x.position[1];
x.position = [left, top];
Copy link to clipboard
Copied
Ok, thus impossible with property position, thank you because i don't saw it in documentation 😕
It's same for all array about illustrator object and illustrator properties or just for property position ?
Copy link to clipboard
Copied
No, it's not impossible. Just like carlos mentioned, you simply have to feed it an array. but you don't need to manually populate all of the elements of the array.. you can pull one of the values right out of the existing position array.
x.position = [10,x.position[1]];
Copy link to clipboard
Copied
Yes, i do it, thank you.
Just, I don't undestand why I can just write pathItem.position[0] = newValue
Thx to take time for answer me
Copy link to clipboard
Copied
Salut !
La vie est dure...
// JavaScript Doc
var docRef = documents.add( DocumentColorSpace.CMYK,600,800);
docRef.rulerOrigin = [0,0];
ogjRect = docRef.pathItems.rectangle(750,20,100,100);
redraw();
alert(ogjRect.position);
var dx = 5;
for (var i = 1; i < 50; i++) {
ogjRect.position = [20+dx*i,750];
redraw();
}
alert(ogjRect.position)
for (var j = 1; j < 50; j++) {
ogjRect.position = [ogjRect.position[0]-dx,ogjRect.position[1]];
redraw();
}
alert(ogjRect.position)
de elleere
position Array de 2 nombres
Copy link to clipboard
Copied
Ah vous parlez français, c'est cool.
Sinon, j'ai fais a peu près ça pour contourner le problème.
C'est dommage que le fait que la propriété position ne prend qu'un couple de valeurs, ne soit pas écrit dans la documentation ExtendScript.
Copy link to clipboard
Copied
function test()
{
var docRef = app.activeDocument;
var path = docRef.pageItems[0];
path.left = 10;
path.top = 20;
}
test();
Copy link to clipboard
Copied
Thank you I tried left and top but left and top include stroke weight @@
Find more inspiration, events, and resources on the new Adobe Community
Explore Now