Explorar el Código

added clearSequence method

eLandon hace 4 años
padre
commit
a8204f5f31
Se han modificado 2 ficheros con 34 adiciones y 14 borrados
  1. 33 13
      SequenceMgr.js
  2. 1 1
      testSequenceMgr.noisette

+ 33 - 13
SequenceMgr.js

@@ -14,7 +14,7 @@ keys are grouped by name, and groups can be saved/loaded to a file
 var rebuildValues = script.addTrigger("rebuild values", "adds a key at current cursor position" );
 var refreshKeys = script.addTrigger("refresh keys", "truc");
 var printKeys = script.addTrigger("printKeys","truc");
-var moveKey = script.addTrigger("moveKey","truc");
+var clearSeq = script.addTrigger("clear Sequence","truc");
 
 
 var sequence_structure = {	params: {}, 
@@ -80,7 +80,7 @@ function moduleValueChanged(value){
 }
 
 function scriptParameterChanged(param){
-	script.log("paramchanged" + param.name);
+	script.log("scriptparamchanged" + param.name);
 	// if (param.name == "printKeys" ){printKeys();}
 	// if(param.name == "newKey"){
 	// 	var key = root.sequences.sequence.layers.mapping.automation.addItem();
@@ -95,15 +95,12 @@ function scriptParameterChanged(param){
 	// 	root.sequences.sequence.layers.mapping.automation.key2.position.set(10.);
 	// }
 	if (param.is(printKeys) ){printKeys();}
-	if(param.is(rebuildValues)){rebuildValuesStructure();	}
-
+	if(param.is(rebuildValues)){rebuildValuesStructure();}
 	if (param.is(refreshKeys)){
 		script.log("refreshKeys");
 		refreshKeysList();
 	}
-	if (param.is(moveKey)){
-		root.sequences.sequence.layers.mapping.automation.key2.position.set(10.);
-	}
+	if (param.is(clearSeq)){clearSequence();}
 
 }
 
@@ -114,17 +111,19 @@ function scriptParameterChanged(param){
 
 function printMethodsAndProperties(obj){
 	script.log(" ");
-	script.log("  METHODS OF " + obj.getControlAddress());
+	// var name = obj.getControlAddress() == undefined ? "object" : obj.getControlAddress();
+	var name = "object";
+	script.log("  METHODS OF " + name);
 	var methods = util.getObjectMethods(obj);
 	for(var i=0 ; i<methods.length ; i++){
 		script.log("  "+ methods[i]);
 	}
-	script.log("  PARAMETERS OF " + obj.getControlAddress());
+	script.log("  PARAMETERS OF " + name);
 	var props = util.getObjectProperties(obj, true, false);
 	for(var i=0 ; i<props.length ; i++){
 		script.log("  "+ props[i]);
 	}
-	script.log("  OBJECTS OF " + obj.getControlAddress());
+	script.log("  OBJECTS OF " + name);
 	var props = util.getObjectProperties(obj, false, true);
 	for(var i=0 ; i<props.length ; i++){
 		script.log("  "+ props[i]);
@@ -230,10 +229,23 @@ function rebuildValuesStructure() {
 }
 
 ///////////////////////		TIMELINE FUNCTIONS		///////////////////////
+function clearSequence(){
+	
+	var sequence = root.sequences.getItemWithName(sequence_structure.params.sequence) ;
+	script.log("clearing all keys and cues of sequence : "+sequence.name);
+	sequence.cues.removeAll();
+	var layers = sequence.layers.getItems();
+	if(layers.length){
+		for (var i = 0; i<layers.length; i++){
+			layers[i].automation.removeAll();
+		}
+	}
+
+}
 
 function refreshKeysList(){
 
-	var sequence = root.sequences.getItemWithName(local.parameters.sequence.getKey(0));
+	var sequence = root.sequences.getItemWithName(sequence_structure.params.sequence);
 	var cues = sequence.cues.getItems();
 	sequence_structure.keys.cues = {};
 	if(cues.length){
@@ -260,7 +272,8 @@ function refreshKeysList(){
 					var currentkey = layers[i].automation.getItems()[j] ;
 					sequence_structure['keys']['layers'][layers[i].name][currentkey.name] = {
 																				position : currentkey.position.get(),
-																				value : currentkey.value.get()
+																				value : currentkey.value.get(),
+																				// group : currentkey.group.get()
 																				};
 					// script.log(tl_keyframes['keys'][currentLayer.name][currentkey.name].value);
 				}
@@ -271,9 +284,15 @@ function refreshKeysList(){
 	// myFile.writeFile(JSON.stringify(tl_keyframes), 1);
 }
 
+// function writeKeyGroup(){
+// 	var groups = sequence_structure.groups
+// }
+
 function createNewGroup(seqName){
 	//create a cue and a key in each layer at cursor position in selected sequence
-	
+	var groupIndex =  util.getObjectProperties(sequence_structure.groups) ;
+	script.log(groupIndex.length);
+	// printMethodsAndProperties(groupIndex);
 	var seq = root.sequences.getItemWithName(seqName);
 	var currentTime = seq.currentTime.get() ;
 	// var currentTime = local.values.newGroup.groupTime.get();
@@ -290,6 +309,7 @@ function createNewGroup(seqName){
 			newKey.position.set(currentTime);
 			script.log(local.values.newGroup.layersValues[layers[i].name].get());
 			newKey.value.set(local.values.newGroup.layersValues[layers[i].name].get());
+			newKey.addStringParameter("group", "key is part of this group","mongroupe");
 			layers[i].automation.reorderItems();
 		}
 	}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1 - 1
testSequenceMgr.noisette