Place item from library - to X Y coordinates
I'm trying to script the placement of an object from the library (it does other things but only thing it doesn't do is place it where I want it).
So I have the script set to 0,0 absolute
Then offset X= -120 and Y= 5
But in different document sizes it doesn't go to the same place - if the page has a spread etc.
For the record it's fine if it places on the page and I move manually - but hey if the script can reposition it in the why not - right?
I can't get it consistently to be in the position I want
if (placedAsset && placedAsset.length > 0) {
var obj = placedAsset[0];
// Save current preferences
var oldRuler = doc.viewPreferences.rulerOrigin;
var oldAnchor = app.activeDocument.selectionPreferences.anchorPoint;
// Set positioning reference to page origin and top left anchor
doc.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
app.activeDocument.selectionPreferences.anchorPoint = AnchorPoint.TOP_LEFT_ANCHOR;
// Move absolutely to 0, 0
obj.move([0, 0]);
// Offset in mm converted to points
var offsetX = -120 * 2.83465; // mm to pt
var offsetY = 5 * 2.83465;
obj.move([offsetX, offsetY]);
// Restore preferences
doc.viewPreferences.rulerOrigin = oldRuler;
app.activeDocument.selectionPreferences.anchorPoint = oldAnchor;
}

