Skip to main content
March 5, 2014
Answered

Please show or instruct how to create the arrayOfValues value parameter for setValuesAtTimes method?

  • March 5, 2014
  • 1 reply
  • 2936 views

Hello AEScriptComm,

                                   i have a few, small scripts that use the setValueAtTime method successfully placing a keyframe on the Layers existing maskPath, but as you could see in the scripts below, using setValueSatTimeS results in errors ie: "Array is not of the correct type", "Value is not an Array"  or "Null is not an object", depending on,..

A) which variable is used as Value parameter IE:

.maskPath;

.maskPath.value;

.maskPath.value.vertices

B) which type of array is used as Value parameter as in:

var addTheseKeys = new Array((1,2,3,4);    (as Time parameter),..

(with Either)

var keyValues = new Array([10,10],[100,100],[15,50],[100,120]);             ...." ]) "

(OR)

var keyValues = [[10,10],[100,100],[15,50],[100,120]];                               ...(Array of arrays? RE: " ]] " )

I've just read a "push" of values into an Array may be required?, but i hoped anyone familiar with setValuesAtTimes could please show,..

1) ..how to create the arrayOfValues value parameter for setValuesAtTimes method?

1a): WORKING setValueAtTime script...

// app.project.item(1).layer(1).property(“Masks”).property(“Mask 1”);

var myProperty    = app.project.item(1).layer(1).mask(1).maskPath;

myShape             = app.project.item(1).layer(1).mask(1).maskPath.value;

myProperty.setValueAtTime(1.0,myShape);

1b): FAILING setValuesAtTimes script...

// var prop1           = app.project.item(1).layer(1).property("ADBE Transform Group").property("ADBE Position");

var fourKeys           = 4;

var addTheseKeys = new Array(1,2,3,4,);

var keyValues         = new Array([10,10], [100,100], [15,50], [100,120]);

var myProperty      = app.project.item(1).layer(1).mask(1).maskPath;

myShape               = app.project.item(1).layer(1).mask(1).maskPath.value;

var myVertices       = app.project.item(1).layer(1).mask(1).maskPath.vertices;

myProperty.setValuesAtTimes(addTheseKeys, keyValues);

app.beginUndoGroup("Keys");

//~ for(var k=0; k<fourKeys; k++)

//~ {

//~ prop1.setValueAtTime(addTheseKeys, keyValues);

//~ }

// myProperty.setValuesAtTimes(addTheseKeys, keyValues);

app.endUndoGroup();

..thanks for any advise\suggestions,

J

This topic has been closed for replies.
Correct answer UQg

A) .maskPath.value; it is always a Shape(). (maskPath is just a property, not a shape on its own, and maskPath.value.vertices only represents a part of the shape data.)

B) none of what you propose....that's why your failed script fails.

var keyValues = new Array([10,10],[100,100],[15,50],[100,120]); and

var keyValues = [[10,10],[100,100],[15,50],[100,120]]; are equally good as arrays of points, the only thing is that keyValues should be arrays of Shape() objects.

Read the scripting guide for how to declare a Shape, or this post (just wrote it...): http://forums.adobe.com/thread/1419866?tstart=0

Your keyValues array should look like this: [keyValues0, keyValues1, keyValues2, keyValues3], where each entry is a Shape().

Xavier.

1 reply

UQg
UQgCorrect answer
Legend
March 5, 2014

A) .maskPath.value; it is always a Shape(). (maskPath is just a property, not a shape on its own, and maskPath.value.vertices only represents a part of the shape data.)

B) none of what you propose....that's why your failed script fails.

var keyValues = new Array([10,10],[100,100],[15,50],[100,120]); and

var keyValues = [[10,10],[100,100],[15,50],[100,120]]; are equally good as arrays of points, the only thing is that keyValues should be arrays of Shape() objects.

Read the scripting guide for how to declare a Shape, or this post (just wrote it...): http://forums.adobe.com/thread/1419866?tstart=0

Your keyValues array should look like this: [keyValues0, keyValues1, keyValues2, keyValues3], where each entry is a Shape().

Xavier.

March 5, 2014

Thx Xavier,

i'll take time looking over website and reply,

great to finally know keyValues Array = Shape() objects, searching days and could find nothing online on its Value array or required elements type. Although i tried via: var myShape = new shape()   ,.. then used myShape as setValuesAtTimes(times , myShape); , right direction maybe, but not enought elements.

1a): WORKING setValueAtTime script, actually does work but i'd rather do it correctly, could you tell how to do properly?, unless ofcourse this answer is same as recommended website for 1b).

Will study guide and your thread, hopefully they'll show Shape() objects, array construction as well,..

Really! appreciate it,

Jeff

UQg
Legend
March 5, 2014

Jeff !

setValuesAtTimes(times, myShape); cannot work since both arguments of setValuesAtTimes should be arrays. times=[t0,t1,...] is an array of numbers, and the second argument should be an array of values, ie values=[val0, val1, ...] and the kind of val0, val1, val2, etc depends on the property you are dealing with. For opacity they all should be numbers in [0,100], for a position they all should be arrays [x,y] or [x,y,z], and for a maskPath, they all should be shape objects.

You should definitely read the guide for both this function and the Shape() class.

Stick to setValueAtTime(time, value) to start with. Your working example reads the maskPath.value (it is a Shape() object) and pastes it a time=1 on the same property. To set a value that you want to define yourself with vertices etc, that would be like this:

// the mask path property:

var myProperty = app.project.item(1).layer(1).mask(1).maskPath;

// the new Shape you want to add as the mask path value:

var myShape = new Shape();

myShape.vertices = [[10,10], [100,100], [15,50], [100,120]];

// myShape.inTangents = [[0,-40], [0,30], [10,20], [20,20]];

// myShape.outTangents = [[20,20], [-30,-10], [30,50], [-30,-40]];

myShape.closed = true;

// set the value:

myProperty.setValueAtTime(1.0,myShape);

If you use the code as is, the shape tangents are not specified and both inTangents and outTangents will default to [[0,0], [0,0], [0,0], [0,0]] and the shape will be made of line segments.

If you uncomment the tangent declarations (i put completely random numbers) AE will use the specified in/outTangents and the shape will be curvy.

Xavier.