Copy link to clipboard
Copied
Dear all,
To the best of my knowledge: ESK is a wrapper around FDK - or something like that. It seems to me that not all FDK functions are mapped to ES functions.
For exeample, in the FDK documentation I find these which have no equivalent in ESK:
An intersting finding concerning decimal TAB: «… Note that the character specified by decimal
must be a single byte character …» IMHO that means that the trigger character can not be a multibyte (UTF-8) character.
But what I miss most - since I best learn by example - is at least one example concerning graphics. For example: place some graphic objects and group them, then rotate the whole thing.
The only one found so far: Graphic Lines · fabianmoronzirfas/extendscript Wiki · GitHub --- for Indesign which seems to have a quite different object model.
Information is not clear to me in many cases [Scripting Guide] - which requires much experimenting, for example for the Line object:
Line.Points : Array of x-y coordinate pairs that specify the line’s vertices. The default coordinate pairs are for the line’s start point and end point.
IMHO the word default is misleading here. Most likely it is meant that the minimum definition are 2 value-pairs for the starting and ending-point.
Line.ObjectAttributes: IMHO an invalid property as it belongs only to an anchored frame («A list of strings, each string expressing an attribute that is specified for an
anchored frame in the Object Properties > Object Attributes dialog box. …»
Rectangle.Height, Rectangle.Width Is this the height resp. width of the skeleton or the total measure including the BorderWidth?
Rectangle.Arrowxxx are IMHO useless - that is, the documentation lists the same properties for a number of graphic objects (most annoying for TextLine or the Math object).
oDoc.NewLine () is a method that requires a parent object. Pass the anchored frame to the DrawLine function and use this:
oDoc.NewLine (oFrame);
Copy link to clipboard
Copied
Hi Klaus,
I am reading this while I am in a meeting 🙂 so I can't say much right now, except that InDesign's object model is radically different from FrameMaker's.
Rick
Copy link to clipboard
Copied
Start with a selected anchored frame with a couple of graphics in it and run the code below.
#target framemaker
var doc, aframe, graphic, group;
doc = app.ActiveDoc;
// Selected anchored frame.
aframe = doc.FirstSelectedGraphicInDoc;
// Make a group inside the anchored frame.
group = doc.NewGroup (aframe);
// Add the graphics in the anchored frame to the group.
graphic = aframe.FirstGraphicInFrame;
while (graphic.ObjectValid () === 1) {
if (graphic.constructor.name !== "Group") {
graphic.GroupParent = group;
}
graphic = graphic.NextGraphicInFrame;
}
// Rotate the group 45 degrees.
group.Angle = 45 * 65536;
// Select the group.
group.GraphicIsSelected = 1;
Copy link to clipboard
Copied
Thanks Rick for this example - these things I do understand (and already experimented with), but how to create graphic objects directly?
I just want to draw a slanted line into the anchored frame. I struggle with the definition of the line properties. At the breakpoint the values are set (even the points), but nothing is drawn.
#target framemaker
var oDoc = app.ActiveDoc, oFrame, cm = 1857713;
Main(oDoc);
function Main(oDoc) {
if (!oDoc.ObjectValid()) {
alert ("A document must be active.");
return;
}
oFrame = oDoc.FirstSelectedGraphicInDoc;
if (!oFrame.ObjectValid()) {
alert ("An anchored frame must be selected.");
return;
}
DrawLine(oDoc);
}
function DrawLine (oDoc) {
var oLine = oDoc.NewLine, oPoints = [[1*cm, 1.5*cm],[5*cm, 1.75*cm]];
oLine.LocX = 1*cm;
oLine.LocY = 1.5*cm;
oLine.Points = oPoints;
oLine.Width = 0.05*cm; // 0.5 mm
oLine.Fill = 0; // full ?
oLine.Color = 0; // black?
$.bp (true);
}
Copy link to clipboard
Copied
oDoc.NewLine () is a method that requires a parent object. Pass the anchored frame to the DrawLine function and use this:
oDoc.NewLine (oFrame);
Copy link to clipboard
Copied
Thank you Rick for this break-through!
Klaus