Copy link to clipboard
Copied
I'm a long term FrameMaker (11) user, but completely new to scripting.
Can someone help me make a script that will set the alignment for all anchored frames in a document to "Left"?
Can someone help me make a script that will set the positioning for all anchored frames in a document to "Below current line"?
Copy link to clipboard
Copied
Hello Inemeth,
The first step is to get access to the currently active document. That is easy enough:
var oDoc = app.ActiveDoc;
This oDoc object contains linked lists of all kinds of elements in the document. The linked list of anchored frames is not a separate, as anchored frames are graphic objects. There is a list of graphic objects, starting with FirstGrapicInDoc. Each object has a pointer to the next one: NextGraphicInDoc. The trick is to figure out whether the current object is an anchored frame or not. This is done by looking at the name of its constructor.
var oGraphic = oDoc.FirstGraphicInDoc;
while( oGraphic.ObjectValid( ) )
{
if( oGraphic.constructor.name == "AFrame" )
{
/* Do something with the anchored frame */
}
oGraphic = oGraphic.NextGraphicInDoc;
}
This is the basic code that will find all anchored frames in your document.
In the commented section you can change alignment and placement by setting these properties to the required valies:
oGraphic.alignment = Constants.FV_ALIGN_LEFT;
oGraphic.placement = Constants.FV_ANCHOR_BELOW;
I hope this helps your current problem, as well as get you on the right track with scripting.
Kind regards from Amsterdam
Jang