Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Finding properties of frame above via scripting

Advocate ,
Feb 17, 2023 Feb 17, 2023

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...

TOPICS
Scripting
991
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 17, 2023 Feb 17, 2023

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
...
Translate
Community Expert ,
Feb 17, 2023 Feb 17, 2023
#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 ());
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 17, 2023 Feb 17, 2023

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2023 Feb 17, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 17, 2023 Feb 17, 2023

Does a TextLoc have a LocY ?!!! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2023 Feb 17, 2023

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);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 17, 2023 Feb 17, 2023
LATEST

Wow. Totally undocumented. Thanks a bundle, Rick.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines