Activity › Forums › Adobe After Effects Expressions › Drawing lines
-
Drawing lines
Posted by Devin Earthman on October 3, 2007 at 4:45 pmSo, I’m not new to scripting (flash, javascript, lightwave, etc), and I’m not new to AFX, but I am new to expressions in AFX! Anyways, I’d like to get my feet wet, and have been reading a LOT of extremely advanced tutorials and whatnot, but I cannot for the life of me find a simple stupid example of line drawing. Practically speaking I have a project where I’d like to draw a line from a fixed text field to a point that is moving in a movie layer (tracked point, perhaps?). Pretty basic, right?
It makes me nervous that I couldn’t find anything about manipulating an individual vertex on a path, and that it apparently requires some javascript plugin to do so, so would it be easier to just create the line with an expression? Please tell me this is possible!
Thanks in advance
Mike Smartt replied 14 years, 5 months ago 7 Members · 10 Replies -
10 Replies
-
Kevin Camp
October 3, 2007 at 5:49 pmunfortunately you can’t use expressions on a mask (or its points), which is what i think you are trying to do…
however the beam effect, which simply draws a line (although by default that line looks like a light saber) between 2 points. you can attach one point to your tracked point and set the other point where it needs to be and you should get what your looking for (or what i think you are looking for).
Kevin Camp
Designer – KCPQ, KMYQ & KRCW -
Mike Clasby
October 3, 2007 at 7:34 pmOverview:
The Beam Effect on a New Solid with expressions on Starting and Ending Point to attach them to the text and to the Track Point.
Details:
1) Add a new Black Solid and to that the Beam Effect, you can make the Start and End Points attach to the tracker and the text respectively.
2) Pickwhip from the Beam>Starting Point to the Text’s Position, to get:
thisComp.layer(“My Text”).position
If you want to add a little offset, keep going, otherwise skip to 2), below.
With -
Mike Clasby
October 3, 2007 at 8:20 pmIf you don’t want the “value +” but want to plug the number straight into the expression, try this (on Ending Point):
xO = 100; // x offset
yO = 100; // y offset
aPoint = thisComp.layer(“MVI_3039.AVI”).motionTracker(“Tracker 1”)(“Track Point 1”).attachPoint;
aPoint + [xO,yO]And this (on Starting Point):
xO = 100; // x offset
yO = 100; // y offset
aPoint = thisComp.layer(“My Text”).position;
aPoint + [xO,yO]Adjust xO and yO as needed. You could even tie them to a slider for more control.
-
Mike Clasby
October 3, 2007 at 9:04 pmThat first expression should have been:
xO = 100; // x offset
yO = 100; // y offset
aPoint = thisComp.layer(“My Video Layer”).motionTracker(“Tracker 1”)(“Track Point 1”).attachPoint;
aPoint + [xO,yO]I had my footage name in for “My Video Layer”, line 3.
-
Devin Earthman
October 3, 2007 at 9:12 pmThanks a lot for the in-depth help! It’s disappointing to me that you have to do it that way, but that’s life I suppose
-
Mike Clasby
October 3, 2007 at 9:15 pmYou can do this with expressions. There are two scripts and both can apply expressions to mask vertices, but the expressions are converted to keyframes. First you need to download this Script (better than the other one for expressions), maskPointsExpression.jsx:
https://www.nabscripts.com/Downloads/downloads_en_2.php?id=6
Download, then copy/move the jsx file “maskPointsExpression.jsx” to AE’s Script Folder, then open AE.
1) Add a new solid.
2) With the Pen Tool, draw a two-point mask, anywhere (OK, keep it on the screen).
3) Add Stroke. Choose the “On Transparent” dropdown at the bottom. Check all masks for now, change to the mask created later.
4) File>Run Script>Choose “MaskPointsExpressions.jsx” and you get the dialog Panel for the script.
Click the radio button, “Position Expression.
Select the mask and click the “calculate” button. It should say 2.
Selection, check the custom box.
You can click the “display num” to see which is vertex 1 and which is 2, It adds two temporary layers above. Selecting the 1 or 2 for choosing which one gets which expression.
I’m assuming the text is Above, so I typed 1 in the box under custom, then selected that vertex, 1, on the screen (you get a little box around it). Paste in the expression for My Text (last post) in the box right under the radio button “Position Expression’ (that should still be checked).xO = 100; // x offset change as needed
yO = 100; // y offset change as needed
aPoint = thisComp.layer(“My Text”).position;
aPoint + [xO,yO]Try to get close with the xO and yO because it will calculate keyframes that must be recalculated if you change the offset.
Now, type 2 in the box under “Custom”, select vertex 2, and Paste the expression for “My Video Layer” into that Position box again:
xO = 100; // x offset
yO = 100; // y offset
aPoint = thisComp.layer(“My Video Layer”).motionTracker(“Tracker 1”)(“Track Point 1”).attachPoint;
aPoint + [xO,yO]Select the mask again, and hit the “OK”.
The Script will calculate a new mask named “Animated mask” right under your original one.
In Stroke choose the new mask.
That should do it.
I
-
Thomas Passow
January 9, 2008 at 8:11 pmIt looks like this will work great for a 2D line, but I have seen this effect used where a line redraws in Zdepth as well. Instead of Beam, can anyone recommend a 3D solution that will draw a line in After Effects?
you can see what I am referring to by checking out the Target commercial in the portfoliio of exopolis here:
https://www.exopolis.com/home/portfolio.php -
Jaygo Bloom
October 27, 2008 at 5:37 pmHi!
Is this thread relevant with cs3 and the new cs4 anymore? I really want to follow the examples on this page but the maskpointexpression.jsx is not available from here anymore?
https://www.nabscripts.com/Downloads/downloads_en_2.php?id=7
has anyone got a copy they can make available? does anyone know of a way around having to use this script?
thanks
J -
Phil Thee
August 26, 2010 at 3:15 amyou can find this script and many others… not very far actually
https://www.nabscripts.com/
go to the downloads section
Reply to this Discussion! Login or Sign Up