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

How to get the object style properties?

Community Expert ,
Jun 09, 2022 Jun 09, 2022

Copy link to clipboard

Copied

Dear Friends,
I can get a paragraph style by

 

 

oPgfFmt = oDoc.GetNamedPgfFmt(sFormat);

 

 

However, I have not found a method to get an equivalent for the object style

 

 

oObjStyle = oDoc.GetNamedGraphicsFmt (sStyle); // not correct

 

 

The famous chm "Adobe FrameMaker-12 Object Model" is outdated and there is nothing relevant in the FDK documentation!
I need to know this to be able to get the properties and then re-apply them to an object in order to remove an override.
Any ideas?

Edit

The ESTK Object Model Viewer is also of no help.

The following script to collect the available styles works as intended:

 

 

KLD_F.GetObjFmtList = function (oDoc, asObjFmts) { // =========
//=== Fill array with list of Object format names
var sObjFmt;  // name in Catalogue
sObjFmt = oDoc.FirstGraphicsFmtInDoc;
  asObjFmts.length = 0;
  while(sObjFmt.ObjectValid() == true) {
    asObjFmts.push (sObjFmt.StyleTag);
    sObjFmt = sObjFmt.NextGraphicsFmtInDoc;
  }
  asObjFmts.sort (KLD_F.SortNoCase); // otherwise random order !
} //--- end GetObjFmtList --------------------------------------

 

In particular, this is not possible (I get a loop situation in line 4 and FM must  be killed)

function ApplyObjectStyle (oDoc, oObject, sStyle) { // ==============
var oObjStyle, oProps, sStyle;
  oObjStyle = oDoc.FirstGraphicsFmtInDoc;         // what is this?
  oObjStyle = oDoc.GetNamedGraphicsFmt (sStyle);  // LOOP / TILT
  if (oObjStyle.ObjectValid()) {
    oProps = oObjStyle.GetProps();
    oObject.SetProps(oProps);
  } else {
    oObject.StyleTag = sStyle;
  }
} //--- end ApplyObjectStyle ----------------------------------------

 

TOPICS
Scripting

Views

233

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 , Jun 15, 2022 Jun 15, 2022

From Adobe (Priya21933415etri) It got the information how to do it. It works in most cases. The script looks now like this

/* FindObjectStyle.jsx ================================================
   • Use Find to search for an object with style override
   • The object will be selected. Depening on the type of object
     the wrapping object (e.g. paragraph) is selected.
   • Function main drills down to the object with the override
   • Now run this script. 
====================================
...

Votes

Translate

Translate
Community Expert ,
Jun 11, 2022 Jun 11, 2022

Copy link to clipboard

Copied

have now asked in the beta forum to trigger an answer from Adobe...

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 ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

From Adobe (Priya21933415etri) It got the information how to do it. It works in most cases. The script looks now like this

/* FindObjectStyle.jsx ================================================
   • Use Find to search for an object with style override
   • The object will be selected. Depening on the type of object
     the wrapping object (e.g. paragraph) is selected.
   • Function main drills down to the object with the override
   • Now run this script. 
==================================================================== */
#target framemaker
main ();

function main () {
  var aItems = [], j, n, oDoc = app.ActiveDoc, oObject, sStyleTag;
  oObject = oDoc.TextSelection;
  if (oObject.beg.obj.constructor.name == "Pgf") {
    oObject = oObject.beg.obj;
    aItems =  oObject.GetText (Constants.FTI_FrameAnchor);  // text objects
    n = aItems.length;
    for (j = 0; j < n; j++) {
      oObject = aItems[j].obj;
      sStyleTag = oObject.StyleTag;
      ApplyObjectStyle (oDoc, oObject, sStyleTag);// Re-apply style
    }
  } else {
    oObject = oDoc.FirstSelectedGraphicInDoc;
    sStyleTag = oObject.StyleTag;
    ApplyObjectStyle (oDoc, oObject, sStyleTag); // Re-apply style
  }
} //--- end Main ------------------------------------------------------

function ApplyObjectStyle (oDoc, oObject, sStyle) { // ================
var oObjStyle, oGraphicsFmt, oProps, sStyle;

  oGraphicsFmt = oDoc.FirstGraphicsFmtInDoc; // inspect catalogue
  while (oGraphicsFmt.ObjectValid() && (oGraphicsFmt.StyleTag != sStyle)) {
    oGraphicsFmt = oGraphicsFmt.NextGraphicsFmtInDoc;
  }
  oObjStyle = oDoc.GetNamedGraphicsFmt (oGraphicsFmt.StyleTag);
  if (oObjStyle.ObjectValid()) {
    oProps = oObjStyle.GetProps();
    oObject.SetProps(oProps);
  } else {
    oObject.StyleTag = sStyle;
  }
} //--- end ApplyObjectStyle ------------------------------------------

Re-applying the original style to the following objects removes the override:

  • Polygon, circle or other geometric object
  • Copied image

However, the override is not removed - although the original style was re-applied - from the following objects:

  • Anchored frame
  • Math object

It's not nice, but acceptable for me - the situation can probably be defused by defining a BaseStyle which does not contain any settings. But this has to be checked.

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
Enthusiast ,
Jun 21, 2022 Jun 21, 2022

Copy link to clipboard

Copied

LATEST

Hi Klaus,

sorry for my late reply.

I think the problem ist an undefined StyleTag:

Your function:

function ApplyObjectStyle (oDoc, oObject, sStyle) { // ================
var oObjStyle, oGraphicsFmt, oProps, sStyle;

 

So sStyle is undefined, because you use the same variable name twice: sStyle

That is the reason, I use to name all parameters from a function starting with an "f": foDoc, foObject and so on to make it clearer

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