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

Finding properties of frame above via scripting

Advocate ,
Feb 17, 2023 Feb 17, 2023

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

TOPICS
Scripting

Views

385

Translate

Translate

Report

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

Votes

Translate

Translate
Community Expert ,
Feb 17, 2023 Feb 17, 2023

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 ());

Votes

Translate

Translate

Report

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

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. 

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Does a TextLoc have a LocY ?!!! 

Votes

Translate

Translate

Report

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

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);

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Wow. Totally undocumented. Thanks a bundle, Rick.

Votes

Translate

Translate

Report

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