Copy link to clipboard
Copied
I am inserting various frames via context rules in the EDD. I am trying to find a method to access some of the properties of frames that are automatically put on the page by FrameMaker via these formatting rules. Is there anyone who has tried (and succeeded) in doing this ?
I have tried to find all graphic objects in the text frame but these auto-included frames are not there. Finding all graphic objects on the page only gives me the textframe.
I have also tried to the to the frame via the properties of the paragraph for which the FrameAbove property is set, but that only gives me the name of the frame, not a handle to the frame itself. Or is that a hidden property in the propVal ?
Any help would be appreciated - although I know that I am probably walking down untravelled roads again here...
Here is what you need. If I had more time, I would break this out into functions but this will give you the basic concepts:
#target framemaker
var PT, doc, pgf, name, frame, textLoc, prop, locY, lineAscent, pgfLocY;
// Metric unit for a point.
PT = 65536;
// Active document.
doc = app.ActiveDoc;
// Selected paragraph with the Frame Above.
pgf = doc.TextSelection.beg.obj;
// The name of the Frame Above (a string).
name = pgf.TopSeparator;
// The frame object from the reference page.
frame
...
Copy link to clipboard
Copied
#target framemaker
var doc, pgf, name, frame;
// Active document.
doc = app.ActiveDoc;
// Selected paragraph with the Frame Above.
pgf = doc.TextSelection.beg.obj;
// The name of the Frame Above (a string).
name = pgf.TopSeparator;
// The frame object from the reference page.
frame = doc.GetNamedUnanchoredFrame (name);
alert (frame.ObjectValid ());
Copy link to clipboard
Copied
But that gives me the object on the reference page. I was looking for the object as it appears above the paragraph that has the FrameAbove property set. More specifically, I need to know its vertical offset on the page. If there is another way to know the vertical offset of a paragraph on the page (in the text frame) that would work, too.
Copy link to clipboard
Copied
The LocY of a TextLoc is from the baseline of the text to the top of the TextFrame or SubCol (I don't remember which). Then there is a LineAscent property that is the x-height of the text. If you are trying to find the top of the FrameAbove frame, the formula is probably
LocY - LineAscent - UFrame.Height
I don't have time to test this right now, but I will try to post some code later.
Copy link to clipboard
Copied
Does a TextLoc have a LocY ?!!!
Copy link to clipboard
Copied
Here is what you need. If I had more time, I would break this out into functions but this will give you the basic concepts:
#target framemaker
var PT, doc, pgf, name, frame, textLoc, prop, locY, lineAscent, pgfLocY;
// Metric unit for a point.
PT = 65536;
// Active document.
doc = app.ActiveDoc;
// Selected paragraph with the Frame Above.
pgf = doc.TextSelection.beg.obj;
// The name of the Frame Above (a string).
name = pgf.TopSeparator;
// The frame object from the reference page.
frame = doc.GetNamedUnanchoredFrame (name);
// Text location at the beginning of the paragraph.
textLoc = new TextLoc (pgf, 0);
// Baseline offset and line ascent at the text location.
prop = doc.GetTextPropVal (textLoc, Constants.FP_LocY);
locY = prop.propVal.ival / PT; // Convert to points.
prop = doc.GetTextPropVal (textLoc, Constants.FP_LineAscent);
lineAscent = prop.propVal.ival / PT; // Convert to points.
// Top of the paragraph's top offset
pgfLocY = locY - lineAscent;
alert (pgfLocY);
// Subtract the height of the unanchored frame
// to get the actual top offset.
pgfLocY = locY - lineAscent - (frame.Height / PT);
alert (pgfLocY);
Copy link to clipboard
Copied
Wow. Totally undocumented. Thanks a bundle, Rick.