-
Custom language parse, compiler
Hello All,
I have written a small script to automate my and my colleagues usual day to day work, it involves creating keyframes on markers and at specific time.
I was looking at possibility to include a small expression kind of system where I can write small peice of codes to set the keyframe values based on other factors.
Below I have explained my requirement with pseudo code of the script.
function setKeyAt ( property, time, value, expression )
{
var keyIndex = property.addKey( time );
if ( value )
property.setValueAtKey ( keyIndex, val );if ( expression )
{
var val = eval( expression );
property.setValueAtKey ( keyIndex, val );
}
}var prop = PROPERTY_REFERENCE;
var nTime = 1;
var exp = "property.keyValue( keyIndex -2 )";
setKeyAt( prop, nTime, undefined, exp );
above code works for me and creates keys at given time, and assings value which is equal to the value at current index – 2.
I want to extend this and implement a way to incorporate something similar to expressions, so that I can create keys using code
currently what I have is, I am looking for key words in the expression string and then replace those with values based on the current property,
EXAMPLE :
currComp.width
is replaced by evaluated value of below string
var layer = property.propertyGroup( property.propertyDepth );
var comp = layer.containingComp;
comp.width;
Hope I was able to explain my problem, and also hope I am not expecting or attempting too much 😉
Thanks,