Styles for FrameMaker Graphics
If you are making a lot of FrameMaker graphics, such as lines with
arrowheads, the thought of having to change them later can give you nightmares.
Wouldn’t it be nice to have “stylesheets” for graphic objects? With FrameScript,
you can apply “styles” to your graphics so that their properties can be globally
changed.
The key is a hidden property of nearly all FrameMaker objects: the
UserString property. This is a string property where you can store
information about an object. You cannot access this property with the standard
FrameMaker interface.
For an example, consider the simple illustration below. Each of the callout
lines is .5 pt thick and has the arrowhead properties indicated in the dialog
box.

Making a change to your style
Let’s assume for a moment that each of the callout lines already has its
UserString property set to Callout (we will show how to set the value
shortly). Here is how simple it is to change them globally.
// Make a property list with the new properties.
New PropertyList NewVar(vCalloutProps);
Add Property To(vCalloutProps) LineCap(0);
Add Property To(vCalloutProps) ArrowTipAngle(24);
Add Property To(vCalloutProps) ArrowTipAngle(6);
Add Property To(vCalloutProps) ArrowLength(9pt);
Add Property To(vCalloutProps) BorderWidth(1.5pt);
// Loop through the graphics and change the ones marked Callout.
Set vGraphic = ActiveDoc.FirstGraphicInDoc;
Loop While(vGraphic)
If vGraphic.UserString = 'Callout' // Test for style name
Set vGraphic.Properties = vCalloutProps;
EndIf
Set vGraphic = vGraphic.NextGraphicInDoc;
EndLoop
The nice thing about PropertyLists is that you only have to specify the
properties that you want to change. If you just wanted to change the line
weight, you would only have to include the BorderWidth property in the
vCalloutProps PropertyList.
Assigning the UserString property
Of course, a big question remains: how do you assign a value to the
UserString property of your object? Here is how to apply to do it for a
selected graphic.
Set vGraphic = ActiveDoc.FirstSelectedGraphicInDoc;
If vGraphic
Set vGraphic.UserString = 'Callout';
Else
MsgBox 'No selected graphic.';
EndIf
Here is a way to be prompted for the UserString value for a selected
graphic.
Set vGraphic = ActiveDoc.FirstSelectedGraphicInDoc;
If vGraphic = 0
MsgBox 'No selected graphic.';
LeaveSub;
Else
DialogBox Type(String) Title('Enter a style name:')
NewVar(vStyle) Button(vButton);
If vButton = CancelButton
LeaveSub;
Else
Set vGraphic.UserString = vStyle;
EndIf
EndIf
If all of the lines in an anchored frame are callouts, here is some
code to assign a value to the UserString property of all the lines at
once.
Set vFrame = ActiveDoc.FirstSelectedGraphicInDoc;
If vFrame = 0
MsgBox 'Please select an anchored frame.';
LeaveSub;
Else
DialogBox Type(String) Title('Enter a style name:')
NewVar(vStyle) Button(vButton);
If vButton = CancelButton
LeaveSub;
Else
Set vGraphic = vFrame.FirstGraphicInFrame;
Loop While(vGraphic)
If vGraphic.ObjectName = 'Line'
Set vGraphic.UserString = vStyle;
EndIf
Set vGraphic = vGraphic.NextGraphicInFrame;
EndLoop
EndIf
EndIf
Assigning a UserString as you make the callouts
Using a style for your callouts makes inserting them a 2 step process. First,
you draw the line with the arrowhead, and second, you assign the UserString
property to the line. Here is a way to accomplish both with a script. Select an
anchored frame before running this code.
New PointList NewVar(vPointList)
X(6pt) Y(12pt) X(78pt) Y(12pt);
New PropertyList NewVar(vCalloutProps);
Add Property To(vCalloutProps) HeadArrow(1);
Add Property To(vCalloutProps) UserString('Callout');
Set vFrame = ActiveDoc.FirstSelectedGraphicInDoc;
If vFrame = 0
MsgBox 'Please select an anchored frame. ';
LeaveSub;
Else
New Line NewVar(vLine) ParentObject(vFrame) Points(vPointList);
Set vLine.Properties = vCalloutProps;
EndIf
Set vLine.GraphicIsSelected = 1;
The last line in the script selects the new line so that it is ready to drag
into position. If you omit this, the anchored frame will remain selected after
the script runs. Any other initial properties that you want to set for the
callout line should be added to the vCalloutProps propertylist at the top
of the script. The main thing is to set a value for the UserString
property so that your callout will be tagged with a “style.”
As an aside, the first line of the script determines the location of the
endpoints of the callout line. You can add as many pairs of points as you want.
You can use this code
New PointList NewVar(vPointList)
X(6pt) Y(12pt) X(6pt) Y(84pt) X(78pt) Y(84pt);
to make right angle lines like this:

You can also set up a loop to add multiple callouts at once.
New PropertyList NewVar(vCalloutProps);
Add Property To(vCalloutProps) HeadArrow(1);
Add Property To(vCalloutProps) UserString('Callout');
Set vFrame = ActiveDoc.FirstSelectedGraphicInDoc;
If vFrame = 0
MsgBox 'Please select an anchored frame. ';
LeaveSub;
Else
DialogBox Type(Int) Title('How many lines?')
Init(5) NewVar(vQty) Button(vButton);
If vButton = CancelButton
LeaveSub;
Else
Set vTopOffset = 12pt
Loop While(vCounter <= vQty) LoopVar(vCounter)
Init(1) Incr(1)
New PointList NewVar(vPointList)
X(6pt) Y(vTopOffset) X(78pt) Y(vTopOffset);
New Line NewVar(vLine) ParentObject(vFrame)
Points(vPointList);
Set vLine.Properties = vCalloutProps;
Set vTopOffset = vTopOffset + 12;
EndLoop
EndIf
EndIf
A hidden treasure becomes a gold mine
You will find many uses for the UserString property in your scripts. I
have used it in dozens of scripts. Here is an idea that you can explore on your
own. If you import graphics by copying instead of by reference, you can store
the path to the graphic in its UserString property, so you can later find
the source if you need it. And, you can use FrameScript to assign the
path to the UserString automatically as you import the graphic.
|