Hi Vincent,
look into the method insertAnchoredObject() of the anchoredObjectSettings of a rectangle.
This method has two arguments:
[1] storyOffset
[2] anchoredPosition
storyOffset is an insertion point, e.g. the first one of a text frame.
anchoredPosition is an enumerator of type AnchorPosition.
InDesign has three different ones:
AnchorPosition.ABOVE_LINE
AnchorPosition.ANCHORED
AnchorPosition.INLINE_POSITION
To anchor the first rectangle to the first insertion point of the first text frame on page one:
var doc = app.documents[0];
var firstPage = doc.pages[0];
var firstTextFrame = firstPage.textFrames[0];
var firstRectangle = firstPage.rectangles[0];
// Anchor the rectangle:
firstRectangle.anchoredObjectSettings.insertAnchoredObject
(
// Argument storyOffset
firstTextFrame.insertionPoints[0] ,
// Argument anchoredPosition
AnchorPosition.ANCHORED
);
Regards,
Uwe Laubender
( ACP )