ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

ScriptUI - NewPath() question?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
joshua faget
ScriptUI - NewPath() question?
on Nov 20, 2016 at 8:13:15 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);


Return to posts index

Xavier Gomez
Re: ScriptUI - NewPath() question?
on Nov 20, 2016 at 9:02:00 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]