|
@@ -1,17 +1,17 @@
|
|
|
|
|
|
-
|
|
|
+var delCue_Trigger = script.addTrigger("clear cues", "clear all cues in the timeline");
|
|
|
+var clearTL_Trigger = script.addTrigger("clear timeline", "clear all cues and keys in the timeline");
|
|
|
|
|
|
- This templates shows what you can do in this is module script
|
|
|
- All the code outside functions will be executed each time this script is loaded, meaning at file load, when hitting the "reload" button or when saving this file
|
|
|
-*/
|
|
|
+var myFile = script.addFileParameter("textFile", "this is a text file");
|
|
|
+var myTrigger = script.addTrigger("My Trigger", "Trigger description");
|
|
|
+
|
|
|
+var tl_keyframes = {cues : {}, keys : {}} ;
|
|
|
+var tl_refresh_rate = 0.5;
|
|
|
+
|
|
|
+var file_keyframes = {groups : 0} ;
|
|
|
|
|
|
|
|
|
-
|
|
|
-var myFloatParam = script.addFloatParameter("My Float Param","Description of my float param",.1,0,1);
|
|
|
-var myFile = script.addFileParameter("textFile", "this is a text file");
|
|
|
-
|
|
|
|
|
|
-var myTrigger = script.addTrigger("My Trigger", "Trigger description");
|
|
|
|
|
|
var myBoolParam = script.addBoolParameter("My Bool Param","Description of my bool param",false);
|
|
|
var myFloatParam = script.addFloatParameter("My Float Param","Description of my float param",.1,0,1);
|
|
@@ -32,6 +32,110 @@ var myEnumParam = script.addEnumParameter("My Enum Param","Description of my enu
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function refresh_tl_keys(){
|
|
|
+
|
|
|
+ if(root.sequences.keys.cues.items.length){
|
|
|
+ for (var i = 0 ; i < root.sequences.keys.cues.items.length ; i++){
|
|
|
+ tl_keyframes['cues']['cue'+i] = {index : i};
|
|
|
+ tl_keyframes['cues']['cue'+i]['name'] = root.sequences.keys.cues.items[i].name;
|
|
|
+ tl_keyframes['cues']['cue'+i]['time'] = root.sequences.keys.cues.items[i].time.get();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(root.sequences.keys.layers.items.length){
|
|
|
+ for (var i = 0 ; i < root.sequences.keys.layers.items.length ; i++){
|
|
|
+ var currentLayer = root.sequences.keys.layers.items[i] ;
|
|
|
+ tl_keyframes['keys'][currentLayer.name] = {};
|
|
|
+
|
|
|
+
|
|
|
+ if(currentLayer.automation.items.length){
|
|
|
+
|
|
|
+ for (var j = 0 ; j < currentLayer.automation.items.length ; j++){
|
|
|
+
|
|
|
+ var currentkey = currentLayer.automation.items[j] ;
|
|
|
+ tl_keyframes['keys'][currentLayer.name][currentkey.name] = {
|
|
|
+ position : currentkey.position.get(),
|
|
|
+ value : currentkey.value.get()
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function clear_tl_cues(){
|
|
|
+ if(root.sequences.keys.cues.items.length){
|
|
|
+ for (var i = root.sequences.keys.cues.items.length-1 ; i>=0 ; i--){
|
|
|
+ root.sequences.keys.cues.removeItem(root.sequences.keys.cues.items[i].name);
|
|
|
+ }
|
|
|
+ script.log("Cleared all cues");
|
|
|
+ }
|
|
|
+ else {script.log("no cues to clear");}
|
|
|
+}
|
|
|
+
|
|
|
+function clear_tl_keys(){
|
|
|
+ if(root.sequences.keys.layers.items.length){
|
|
|
+ for (var i = root.sequences.keys.layers.items.length-1 ; i >=0 ; i--){
|
|
|
+ if(root.sequences.keys.layers.items[i].automation.items.length){
|
|
|
+ for (var j = root.sequences.keys.layers.items[i].automation.items.length-1 ; j >= 0 ; j--){
|
|
|
+ root.sequences.keys.layers.items[i].automation.removeItem(root.sequences.keys.layers.items[i].automation.items[j].name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ script.log("Cleared all keys");
|
|
|
+ }
|
|
|
+ else{script.log("no keys to clear");}
|
|
|
+}
|
|
|
+function clear_tl_full(){
|
|
|
+ clear_tl_cues();
|
|
|
+ clear_tl_keys();
|
|
|
+}
|
|
|
+
|
|
|
+function create_keyGroup(){
|
|
|
+
|
|
|
+ var groupIndex = file_keyframes.groups;
|
|
|
+ script.log(groupIndex);
|
|
|
+
|
|
|
+ var tempValues = {
|
|
|
+ position: root.sequences.keys.currentTime.get() ,
|
|
|
+ pan : root.sequences.keys.layers.pan.mapping.outValue.get(),
|
|
|
+ tilt : root.sequences.keys.layers.tilt.mapping.outValue.get(),
|
|
|
+ zoom : root.sequences.keys.layers.zoom.mapping.outValue.get(),
|
|
|
+ dim : root.sequences.keys.layers.dim.mapping.outValue.get(),
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ var inCue = root.sequences.keys.cues.addItem();
|
|
|
+ inCue.time.set(tempValues.position);
|
|
|
+ script.log(inCue.name);
|
|
|
+ var outCue = root.sequences.keys.cues.addItem();
|
|
|
+ outCue.time.set(tempValues.position+1.);
|
|
|
+ script.log(outCue.name);
|
|
|
+
|
|
|
+ var groupKeys = {in:{}, out:{}} ;
|
|
|
+ var layers = root.sequences.keys.layers.items ;
|
|
|
+ if(layers.length){
|
|
|
+ for (var i = 0 ; i<layers.length ; i++){
|
|
|
+ tempKey = layers[i].automation.addItem();
|
|
|
+ tempKey.position.set(tempValues.position);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
The init() function will allow you to init everything you want after the script has been checked and loaded
|
|
|
WARNING it also means that if you change values of your parameters by hand and set their values inside the init() function, they will be reset to this value each time the script is reloaded !
|
|
@@ -42,7 +146,15 @@ function init()
|
|
|
|
|
|
|
|
|
|
|
|
- script.log(myFile.getAbsolutePath());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -54,26 +166,37 @@ function scriptParameterChanged(param)
|
|
|
script.log("Parameter changed : "+param.name);
|
|
|
if(param.is(myTrigger)){
|
|
|
script.log("Trigger !");
|
|
|
- var testJSON = {} ;
|
|
|
- testJSON['A']='truc';
|
|
|
- testJSON['B']=12;
|
|
|
- myFile.writeFile(JSON.stringify(testJSON), 1);
|
|
|
- }
|
|
|
+ create_keyGroup();
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (param.is(delCue_Trigger)){clear_tl_cues();}
|
|
|
+ else if (param.is(clearTL_Trigger)){clear_tl_full();}
|
|
|
else if(param.is(myEnumParam)) script.log("Label = "+param.get()+", data = "+param.getData());
|
|
|
- else script.log("Value is "+param.get());
|
|
|
- script.log(myFile.readFile());
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
This function, if you declare it, will launch a timer at 50hz, calling this method on each tick
|
|
|
*/
|
|
|
-
|
|
|
+var tl_refresh_delta = 0.;
|
|
|
+
|
|
|
+
|
|
|
function update(deltaTime)
|
|
|
{
|
|
|
- script.log("Update : "+util.getTime()+", delta = "+deltaTime);
|
|
|
+ tl_refresh_delta += deltaTime ;
|
|
|
+ if (tl_refresh_delta > tl_refresh_rate){
|
|
|
+ tl_refresh_delta = 0. ;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
-*/
|
|
|
+
|
|
|
|
|
|
|
|
|
|