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 ----------------------------------------
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.
====================================
Copy link to clipboard
Copied
have now asked in the beta forum to trigger an answer from Adobe...
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:
However, the override is not removed - although the original style was re-applied - from the following objects:
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.
Copy link to clipboard
Copied
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