Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions ScriptUI – NewPath() question?

  • ScriptUI – NewPath() question?

    Posted by Joshua Faget on November 20, 2016 at 8:13 am

    Hello,

    I want to create a UI element that is composed of a stroked path.
    But I can’t seem to figure out how its supposed to be done…

    var Win = new Window("palette",'Window');
    var grp = Win.add("group",[0,0,300,200]);

    var PathPoints = [[0,0],[10,10],[0,10]] //example path.
    var Path = grp.graphics.newPath(PathPoints);
    var strokeBrush = grp.graphics.newPen( grp.graphics.BrushType.SOLID_COLOR, [1, 1, 1, 1],2);
    Path.strokePath(strokeBrush);

    Xavier Gomez replied 9 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Xavier Gomez

    November 20, 2016 at 9:02 am

    The path properties are not exposed to scripting apparently.
    You need to use the moveTo() and lineTo() methods:

    var g = grp.graphics;
    var strokePen = g.newPen( g.PenType.SOLID_COLOR, [1, 1, 1, 1],2);
    g.newPath();
    g.moveTo(0,0);
    g.lineTo(10,10);
    g.lineTo(0,10);
    // to close: g.closepath();
    g.strokePath(strokePen, g.currentPath);

    Paths defined this way will only be drawn while the group is drawn. This requires to define grp.onDraw somewhere will all the instructions to draw the group, like above, that is :
    grp.onDraw = function(){ /*some code involving this.graphics*/};
    and in CC it turns out that onDraw is a little bit buggy: sometimes custom graphics defined through onDraw disappear while the user opens a dialog, and are not redrawn afterwards. See also this thread: https://forums.adobe.com/thread/1911167 (harder bug in CC2015 and later). Overall, it seems that it is no longer a good idea to use custom onDraw with ScriptUI.

    Xavier

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy