Copy link to clipboard
Copied
Hello fellows,
I am trying to change properties of a certain condition tag through extendscript.
For example, I'd like add a background color to the condition tag. So I came up with this (faulty) code:
The ES toolkit complains that UseBkColor and BkColor are "undefined", but according to the FM10 Object Reference, these are properties of CondFmt. What am I missing? Thank you for your inputs in advance!
#target framemaker
CondApplBcolor(doc, TestCond);
function CondApplBcolor (doc, TestCond)
{
var doc = app.ActiveDoc;
var TestCond = doc.GetNamedCondFmt(Insert);
if (TestCond.ObjectValid())
{
Props = TestCond.GetProps();
Bcolor_en = GetPropIndex(Props, UseBkColor);
Bcolor = GetPropIndex(Props, BkColor);
Props[Bcolor_en].propVal.ival = 1;
Props[Bcolor].propVal.sval ="Pale Green";
TestCond.SetProps (Props);
return(1);
}
}
Copy link to clipboard
Copied
rombanks,
There is some faultiness to your code indeed Firstly, all these properties live in a big array of constants, named Constants. So, you want these values instead:
Constants.FP_BkColor
Constants.FP_UseBkColor
Secondly, you can't assign a color by name. You have to assign it by its object. Therefore, you need to get the object first:
var color = doc.GetNamedColor("Pale Green");
...and then assign it as an object
Props[Bcolor].propVal.obj = color;
Thirdly, the use of these property value arrays is convoluted and may cause trouble with buggy behavior. Best just to set the property directly:
TestCond.BkColor = color;
Hope this helps,
Russ
Copy link to clipboard
Copied
Hi Russ,
I appreciate your response!
In fact, I wanted to use the constants but I did not find these two in the FM10 scripting guide....
Thank you for your explanation about using properties as objects. I did not know that.
BTW, I can assign a background color to a "regular" condition, but for some reason, I cannot assign it to the track changes condition. Any idea why I cannot do that?
Another question: how do I display the condition properties array using alert()?
Thanks again for your input!
Roman
Copy link to clipboard
Copied
Roman,
Nice to know your name, thanks. Regarding your last post:
- The scripting guide has most things in it, but it is very difficult to decipher, especially for beginners. So no reason to feel you should have found those things.
- I do not know anything about the built-in conditions and don't have time at the moment to experiment. If an operation works on your custom conditions but not a built-in condition, I'd suggest that they are probably off-limits.
- I don't know what you mean exactly by your last question. The alert() box renders a string or a number. So for example, if you wanted to report the background color of a condition, maybe you could do something like this, in order to drill down to the string you need: alert(condition.BkColor.Name)
Russ
Copy link to clipboard
Copied
Russ,
Hi!
Thank you for your response. I am sure you do know these "built-in conditions" -- they are used when the Track Text Edits option is enabled.
Best regards,
Roman
Copy link to clipboard
Copied
Hi Roman,
perhaps this can help you:
PrintPropVals()
PrintPropVal()
PrintTextItem()
PrintTextItems()
Just have a look at the explanations in "FrameMaker Scripting Guide".
Klaus
Copy link to clipboard
Copied
Hi Klaus,
Thank you for your response and for the suggestion!
PrintPropVals() indeed displays an array of CondFmt properties, but the problem is that the properties are presented as numerical values and not as labels (names).
BTW, do you know why the Track Text Edits conditions (add/delete) cannot get a background color? Their font color can still be configured, so they aren't some kind of read-only condition tags.
Thank you!
Copy link to clipboard
Copied
PrintPropVals() indeed displays an array of CondFmt properties, but the problem is that the properties are presented as numerical values and not as labels (names).
You have to "translate" that numbers.
In "FrameMaker Scripting Guide" -> chapter 5 -> Constants you'll find the meaning of those numbers.
e.g. search for "621" and you'll find "Constants.FP_UseFontFamily" in that table.
Copy link to clipboard
Copied
Hi Klaus,
This is good input. Thank you!
Best regards,
Roman
Copy link to clipboard
Copied
Interestingly enough, when I run the script and check the resulting MIF file, I do see the background color tag added to the FM8_TRACK_CHANGES_ADDED condition definition, but the background does not appear in Framemaker. This is a mystery...
Copy link to clipboard
Copied
You don't need to use property lists to change condition properties. You can do this:
var doc = app.ActiveDoc;
var condFmt = doc.GetNamedCondFmt ("FM8_TRACK_CHANGES_ADDED");
var color = doc.GetNamedColor ("Pale Green");
condFmt.BkColor = color;
alert (condFmt.BkColor.Name);
alert (condFmt.UseBkColor);
However, it appears that the built-in (and hidden) track changes conditions can't be changed. You can change them as the code shows, but the changes don't seem to stick.
Copy link to clipboard
Copied
Hi Rick,
Thank you for your response!
That's exactly the problem I have -- FM seems to apply the change (I see it in MIF) but it's not visible in the binary file. Moreover, you can change the font color of these built-in conditions through the GUI - so they don't seem to be Read-Only.
I sent this inquiry to Adobe -- no response so far...
My best regards,
Roman