Quantcast
Channel: Adobe Community: Message List - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 3715

Re: ESTK - draw a graphic

$
0
0

@Ian: Thanks - this lets me see what I have at a selected polyline:

var j, oDoc = app.ActiveDoc, oObject, nPoints;  oObject = oDoc.FirstSelectedGraphicInDoc;  nPoints = oObject.NumPoints  for (j = 0; j < nPoints; j++) {    $.writeln (oObject.Points[j].x, oObject.Points[j].y);  }

 

With Markus' idea I could create the points (see script output), but the drawn graphic is by no means what I expect (reddish polyline) accoring to the Points.

polyline4.png

#target framemaker
var oDoc = app.ActiveDoc, CM = 1857713;           // Constants.FV_Metric_CM not present in ESTK
Main(oDoc);

function DrawPolyLine(oDoc, oFrame, rVertices, iSmooth) { // === Draw a polygon line ====
var j, jMax, minX, maxX, minY, maxY, oPoly = oDoc.NewPolyline(oFrame);
  jMax = rVertices.length/2;                      // number of points  minX = minY = Number.MAX_VALUE;  maxX = maxY = 0;                  // in units  for (j = 0; j < jMax; j++) {    oPoint = new Point (rVertices[j*2]* CM, rVertices[j*2+1]* CM);// convert into internal units
$.writeln (oPoint.x + "   " + oPoint.y);    oPoly.Points.push(oPoint);    if (rVertices[j*2] < minX) {minX = rVertices[j*2];}    if (rVertices[j*2+1] < minY) {minY = rVertices[j*2+1];}    if (rVertices[j*2] > maxX) {maxX = rVertices[j*2];}    if (rVertices[j*2+1] > maxY) {maxY = rVertices[j*2+1];}  }  oPoly.Fill  = 15;                               // equiv Pattern: 0: filled, 7: white, 15: clear  oPoly.Color = 0;                                // black?   oPoly.BorderWidth = 0.05*CM;                    // Stroke-width  oPoly.Dash  = [CM, 0.5, 0.5, 0.2, 0.2];         // not correct yet  oPoly.LocX = minX * CM;  oPoly.LocY = minY * CM;  oPoly.NumPoints = jMax;  oPoly.PolyIsBezier = iSmooth;  oPoly.Width = (maxX - minX) * CM;               // object dimensions  oPoly.Height= (maxY - minY) * CM;               // default : 1/4"  return oPoly;
} //--- end DrawPolyLine

function Main(oDoc) { // ==========================================================================
var oFrame, oLine1, oPoly1;
var rVertices = [4, 1, 3, 3, 8, 3, 6, 2];         // values in cm  if (!oDoc.ObjectValid()) {    alert ("A document must be active.");    return;  }    oFrame = oDoc.FirstSelectedGraphicInDoc;  if (!oFrame.ObjectValid()) {    alert ("An anchored frame must be selected.");    return;  }  if (oFrame.constructor.name === "AFrame") {     // If it is an anchored frame, display its anchor type and width.
//    alert ("Anchor type: " + oFrame.AnchorType + " width in CM: " + oFrame.Width/CM);  }  oPoly1  = DrawPolyLine(oDoc, oFrame, rVertices, 0);  // unsmoothed line
} //--- end Main

Output:

7430852   1857713

5573139   5573139

14861704   5573139

11146278   3715426


Viewing all articles
Browse latest Browse all 3715

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>