Problem creating parabola with AppleScript

I am creating an exact parabola using AppleScript:

tell application id “OGfl”
   tell canvas of front window
      activate
      set lstPoints to {{-200, -200}, {0, 200}, {0, 200}, {200, -200}}
      make new line with properties {bezier point list:lstPoints, line type:bezier, draws shadow:false}
   end tell
end tell

All I get is a straight line. Javascript OmniJS works perfectly for me

var canvas = document.windows[0].selection.canvas;
var g1 = canvas.newLine();
g1.lineType = LineType.Bezier;
g1.bezierPoints = [new Point(-200, -200), new Point(0, 200), new Point(200, -200), new Point(0, 200)];
g1.shadowColor = null;

I am wondering why AppleScript is not working for the parabola or Bezier curves in general. Any help is greatly appreciated.

The points need to be in multiples of 3, and there need to be at least 6 points.

To be confident of the API incantations, probably safest to experiment with:

  • first drawing something similar by hand,
  • and then using Edit > Copy As AppleScript to see what kind of code it returns.

A simple sample of a Bezier snippet generated this way:

tell application "OmniGraffle"
    tell canvas of front window
        make new shape at end of graphics with properties {name:"Bezier", fill:no fill, draws shadow:false, point list:{{108, -29}, {149.5, -135}, {283.5, -205.5}, {283.5, -205.5}, {283.5, -205.5}, {371.5, 100.5}, {371.5, 100.5}, {371.5, 100.5}, {66.5, 77}}, stroke color:{0.0, 0.0, 0.0}, fill color:{0.794417, 0.794436, 0.794426}}
    end tell
end tell

Thanks for the reply @draft8. The problem is with Bezier curves, not Bezier shapes. I have recreated the problem using gif. I’d appreciate any input. Thanks!!

Yes, that does look suspiciously like a bug :-)

You can try emailing support, but I think the bottom line is that the API work has now shifted to the Automation JSContext, and it may be better to do your scripting there, if possible.

Much to my surprise, the JXA does not seem to work, either. The following also produces a straight line.

(function () {
    'use strict';

    var og = Application("OmniGraffle"),
        ds = og.documents,
        d = ds.length ? ds[0] : null,
        cnvs = d ? d.canvases : [],
        cnv = cnvs.length ? cnvs[0] : null,
        gs = cnv ? cnv.graphics : null;

    return gs ? (
        gs.push(
            og.Line({
                bezierPointList: [[-200, -200], [0, 200], [0, 200], [200, -200]],
                drawsShadow: true,
                thickness: 1,
                lineType: 'bezier',
                strokeColor: [0.75, 0.75, 0.75],
            })
        )
    ) : null;

})();

It seems that for the parabola, OmniJS is the only way to go.

I think that’s what theory would predict - AppleScript and JavaScript for Automation are just alternative interfaces to the same osascript library.

As you say, omniJS probably the right instrument to use now.

That makes sense. Thanks for the comments @draft8.

It’s a general problem of bezier lines drawn by scripts. When using a script the control points are placed along the straight lines in direction of the neighboring points of the lines. It also happens with bezier lines with more segments. This is clearly a bug.