Copy link to clipboard
Copied
Hi everyone.
What i am trying is creating an empty frame for graphics.
i´m using Extendscript for this purpose. I can create Frames with Graphic. but no empty Frames.
I Tried following code:
frame = doc.NewGraphicObject (Constants.FO_AnchoredFrame, doc.TextSelection);
frame = doc.NewGraphicObject (Constants.FO_UnanchoredFrame, doc.TextSelection);
frame = doc.NewUnanchoredFrame (doc.TextSelection);
None of those is creating an empty Frame. I have an unstructered Document but tried this with structered documents too.
I tried them one by one, and now i am out of options. I don´t have a clue why this is not working.
I´m using Framemaker 12.
Hope somebody knows what i´m missing.
Rick is correct for the unanchored objects, but one point of clarification for the anchored frame... you are using the wrong method for that. You should use the following, noting that this method requires a text location, not a graphic object:
var frame = doc.NewAnchoredAFrame(doc.TextSelection.beg);
Also, if you want to put an unanchored object on the page with the current insertion point, this might work too, although please note that I did not test this:
var frame = doc.NewUnanchoredFrame(doc.Te
...Copy link to clipboard
Copied
For an unanchored frame, you have to specify a parent object, not a text location.
#target framemaker
var doc = app.ActiveDoc;
var page = doc.FirstBodyPageInDoc;
var frame = doc.NewUnanchoredFrame (page.PageFrame);
This will create a small frame at the upper-left corner of the first page of the active document. Please let me know if you have any questions or comments. -Rick
Copy link to clipboard
Copied
And how would i Inser the Frame at the current selection?
Copy link to clipboard
Copied
Rick is correct for the unanchored objects, but one point of clarification for the anchored frame... you are using the wrong method for that. You should use the following, noting that this method requires a text location, not a graphic object:
var frame = doc.NewAnchoredAFrame(doc.TextSelection.beg);
Also, if you want to put an unanchored object on the page with the current insertion point, this might work too, although please note that I did not test this:
var frame = doc.NewUnanchoredFrame(doc.TextSelection.beg.InTextFrame);
Russ
Copy link to clipboard
Copied
Thank you Russ, But doc.TextSelection.beg.InTextFrame does not work : (
Copy link to clipboard
Copied
It is still not clear to me what you want to do. Do you want to create an anchored frame at the insertion point? Or an unanchored frame on the page?
Copy link to clipboard
Copied
Rick indeed, I was missing the fact that you need to put the unanchored frame on a page, not in a text frame. I got curious and worked up this sample that places an unanchored frame at the insertion point, assuming that the insertion point is in a basic text frame that lives on the page, that frame has no sideheads, and the insertion point is not in a table cell or other weird place. This gets into some complicated stuff... lots of fun, but definitely a hurdle for a beginner. Many possible considerations here.
function insertUnanchoredFrame(doc)
{
var textFrame = doc.TextSelection.beg.obj.InTextFrame;
var page = textFrame.FrameParent;
var newFrame = doc.NewUnanchoredFrame(page);
var prop = doc.GetTextPropVal(doc.TextSelection.beg, Constants.FP_LocX);
newFrame.LocX = prop.propVal.ival + textFrame.LocX;
prop = doc.GetTextPropVal(doc.TextSelection.beg, Constants.FP_LocY);
newFrame.LocY = prop.propVal.ival + textFrame.LocY;
}
Russ
Copy link to clipboard
Copied
I think i want an anchored Frame at the selection. What i mean is when i have a selection in the middle of a sentence, i want to put the frame right inbetween so that the text is around the frame kind of thing
So anchored/unanchored has nothing to do with structured FM ?
Copy link to clipboard
Copied
OK, then Russ's code will work:
var frame = doc.NewAnchoredAFrame (doc.TextSelection.beg);
You may have to change the anchored frames properties after you insert it:
// Set the anchored frame to the insertion point.
frame.AnchorType = Constants.FV_ANCHOR_INLINE;
Copy link to clipboard
Copied
Thank you guys very much !
Copy link to clipboard
Copied
Russ, your first sample puts the anchored frame at the insertion point (or the beginning of the current text selection). You need a little more code for the second example:
#target framemaker
var doc = app.ActiveDoc;
// Get the text location of the current insertion point.
var textLoc = doc.TextSelection.beg;
// get the parent text frame.
var prop = doc.GetTextPropVal (textLoc, Constants.FP_InTextFrame);
var textFrame = prop.propVal.obj;
// Make an unanchored frame on the same page as the text frame.
var frame = doc.NewUnanchoredFrame(textFrame.FrameParent);