Copy link to clipboard
Copied
I want to move the current selection or better yet, paste the clipboard item to a pre-defined X,Y coordinate. I am able to pull the coordinate variables from a text object within the file but I don't know how to write the javascript to "move" the object into place.
I found this script in the InDesign forum. Can I tweak it to work in AI? Running it as-is returns an error: "illegal argument - argument 1".
var s=app.activeDocument.selection[0];
s.move([-.25,-.25])
Here is a sample file: Dropbox - Align_Sample.ai
I want to paste other "fingerprints" to the coordinates listed in the file. I know I'll need to convert the coordinates to points. I can do that although I may not know the best method.
Thanks for any help!
rcraighead schrieb
… but I don't know how to write the javascript to "move" the object …
To answer this scripting question:
1) using translate: move x + 100pt, move y -100pt
var aDoc = app.activeDocument;
aDoc.selection[0].translate(100,-100);
or
2) using pathItem.position: move x + 100pt, move y -100pt
var aDoc = app.activeDocument;
var aSel = aDoc.selection[0];
var SelBounds = aSel.geometricBounds;
aSel.position = new Array( SelBounds[0]+100, SelBounds[1]-100 );
Have fun
Copy link to clipboard
Copied
Why so complicated?
At first: the positions are not plausible. You should recreate your file.
Second: use some effects to do what you want. (see the attached link --> Dropbox - Align_Sample_effect.ai ). You only need one motiv.
All what you have to do in future is: remove the (old) fingerprint and add a new one in the same group. The effects will complete automatically your file.
If that is what you want - have fun.
If you still need a script, please contact us again.
Copy link to clipboard
Copied
At first: the positions are not plausible. You should recreate your file.
This may be because the "Reference Point" is not set to "Centered".
Second: use some effects to do what you want
That was my first thought, but relative coordinate are not always equally spaced. This is to accommodate for laser angle and other imperfections in the production process.
You HAVE provided some food for thought though. Maybe I can create an effect that would reposition the fingerprint or inscription to the correct location. We have about 60 templates with unique coordinates. That'll be a bit of work.
Thank you!
Note: The blue ellipses are currently being used to align elements by using "Align to Key Object".
Copy link to clipboard
Copied
Is this really correct?
0.1 mm is a very long distance (or tolerance? for a laser)
Copy link to clipboard
Copied
I understand these locations change to compensate for the differing angle of the laser in relation to each piece. The laser does not image at 90 degrees. This is required to make each piece appear to be centered.
Edit: pixxxel schubser​, Your ideas helped me realize updating Symbols may be a solution. This could probably be scripted. Each product is laid out separately and added to a single template as the final step. The one-up files are named according to their numeric location in the final layout. Maybe these files could automatically replace the like-named Symbol. I'll think more about this. Thanks for your good advice.
Copy link to clipboard
Copied
rcraighead schrieb
… but I don't know how to write the javascript to "move" the object …
To answer this scripting question:
1) using translate: move x + 100pt, move y -100pt
var aDoc = app.activeDocument;
aDoc.selection[0].translate(100,-100);
or
2) using pathItem.position: move x + 100pt, move y -100pt
var aDoc = app.activeDocument;
var aSel = aDoc.selection[0];
var SelBounds = aSel.geometricBounds;
aSel.position = new Array( SelBounds[0]+100, SelBounds[1]-100 );
Have fun