Browse Source

export cues and keys from tl fixed

eLandon 4 years ago
parent
commit
549fc46be5
1 changed files with 77 additions and 36 deletions
  1. 77 36
      SequenceMgr.js

+ 77 - 36
SequenceMgr.js

@@ -290,6 +290,7 @@ function importSequenceFile(loadFile){
 	var parameters = local.getChild("parameters");
 	parameters.syncRate.set(loadData.parameters.SyncRate);
 	parameters.synchronize.set(loadData.parameters.Synchronize);
+	parameters.monitorKeysCues.set(loadData.parameters.monitorKeysCues);
 	sequence = loadData.parameters.Sequence;
 	if(1){
 
@@ -323,6 +324,7 @@ function importSequenceFile(loadFile){
 			for(var i=0; i<layersList.length; i++ ){
 				var layerType = loadData.values.keys.layers[layersList[i]].type ;
 				var layer = tl_sequence.layers.addItem(layerType);
+
 				layer.setName(layersList[i]);
 				var keysList = util.getObjectProperties(loadData.values.keys.layers[layersList[i]], true, false);
 				if(keysList.length){
@@ -371,10 +373,10 @@ function importSequenceFile(loadFile){
 		}
 
 		// script.log(layersList[0]);
-		doSync = true;
+		
 		// updateSynchronize() ;
 	}
-
+	doSync = true;
 
 }
 
@@ -420,49 +422,86 @@ function exportSequenceFile(fileObj){
 		}
 	}
 
-	var cues = values.keys.cues;
-	var cuesList=util.getObjectProperties(cues, true, false);
-	if(cuesList.length){
-		for(var i=0; i<cuesList.length; i++){
-			var exportCue = exportData.values.keys.cues[cuesList[i]] = {cue:"", time:0.};
-			exportCue.cue = cuesList[i];
-			exportCue.time = cues.getChild(cuesList[i]).time.get();
+	// var cues = values.keys.cues;
+	// var cuesList=util.getObjectProperties(cues, true, false);
+	// if(cuesList.length){
+	// 	for(var i=0; i<cuesList.length; i++){
+	// 		var exportCue = exportData.values.keys.cues[cuesList[i]] = {cue:"", time:0.};
+	// 		exportCue.cue = cuesList[i];
+	// 		exportCue.time = cues.getChild(cuesList[i]).time.get();
 			
+	// 	}
+	// }
+
+	// var layers = values.keys.layers;
+	// var layersList=util.getObjectProperties(layers, true, false);
+	// if(layersList.length){
+	// 	for(var i=0; i<layersList.length; i++){
+	// 		var exportLayer = exportData.values.keys.layers[layersList[i]] = {};
+	// 		var currentLayer = layers.getChild(layersList[i]);
+	// 		var currentLayersKeys = util.getObjectProperties(currentLayer, true, false);
+	// 		exportLayer["type"] = values.keys.layerTypes.getChild(layersList[i]).get();
+	// 		if (currentLayersKeys.length){
+	// 			for(var j=0; j<currentLayersKeys.length; j++){
+	// 				if (exportLayer["type"]!= "Audio"){
+	// 					if(currentLayersKeys[j]!="type"){
+	// 						// script.log(currentLayersKeys[j]);
+	// 						// script.log(groupsList[i]+ "  "+ currentGroupLayers[j]);
+	// 						exportLayer[currentLayersKeys[j]] = {key:"", value:0., time:0.};
+	// 						exportLayer[currentLayersKeys[j]].value = currentLayer.getChild(currentLayersKeys[j]).value.get();
+	// 						exportLayer[currentLayersKeys[j]].key = currentLayer.getChild(currentLayersKeys[j]).name;
+	// 						exportLayer[currentLayersKeys[j]].time = currentLayer.getChild(currentLayersKeys[j]).time.get();
+	// 					}
+	// 				}
+	// 				else {
+	// 					exportLayer[currentLayersKeys[j]] = {clip:"", filePath:0., startTime:0.};
+	// 					exportLayer[currentLayersKeys[j]].filePath = currentLayer.getChild(currentLayersKeys[j]).filePath.get();
+	// 					exportLayer[currentLayersKeys[j]].clip = currentLayer.getChild(currentLayersKeys[j]).name;
+	// 					exportLayer[currentLayersKeys[j]].startTime = currentLayer.getChild(currentLayersKeys[j]).startTime.get();
+	// 				}
+					
+	// 			}
+	// 		}
+	// 	}
+	// }
+
+	//export cues and layers from tl
+	var tl_seq = root.sequences.getItemWithName(sequence);
+	var tl_cues = tl_seq.cues.getItems();
+	if (tl_cues.length){
+		for(var i=0; i<tl_cues.length; i++){
+			exportData.values.keys.cues[tl_cues[i].name] = tl_cues[i].time.get();
+
+
 		}
 	}
+	var tl_layers = tl_seq.layers.getItems();
+	if (tl_layers.length){
+		for(var i=0; i<tl_layers.length; i++){
+			exportData.values.keys.layers[tl_layers[i].name] = {type:tl_layers[i].getType()};
+			if(tl_layers[i].getType()=="Mapping"){
+				var keys = tl_layers[i].automation.getItems();
+				if(keys.length){
+					for(var j=0; j<keys.length; j++){
+						exportData.values.keys.layers[tl_layers[i].name][keys[j].name] = {value: keys[j].value.get(), time:keys[j].position.get()};
 
-	var layers = values.keys.layers;
-	var layersList=util.getObjectProperties(layers, true, false);
-	if(layersList.length){
-		for(var i=0; i<layersList.length; i++){
-			var exportLayer = exportData.values.keys.layers[layersList[i]] = {};
-			var currentLayer = layers.getChild(layersList[i]);
-			var currentLayersKeys = util.getObjectProperties(currentLayer, true, false);
-			exportLayer["type"] = values.keys.layerTypes.getChild(layersList[i]).get();
-			if (currentLayersKeys.length){
-				for(var j=0; j<currentLayersKeys.length; j++){
-					if (exportLayer["type"]!= "Audio"){
-						if(currentLayersKeys[j]!="type"){
-							// script.log(currentLayersKeys[j]);
-							// script.log(groupsList[i]+ "  "+ currentGroupLayers[j]);
-							exportLayer[currentLayersKeys[j]] = {key:"", value:0., time:0.};
-							exportLayer[currentLayersKeys[j]].value = currentLayer.getChild(currentLayersKeys[j]).value.get();
-							exportLayer[currentLayersKeys[j]].key = currentLayer.getChild(currentLayersKeys[j]).name;
-							exportLayer[currentLayersKeys[j]].time = currentLayer.getChild(currentLayersKeys[j]).time.get();
-						}
 					}
-					else {
-						exportLayer[currentLayersKeys[j]] = {clip:"", filePath:0., startTime:0.};
-						exportLayer[currentLayersKeys[j]].filePath = currentLayer.getChild(currentLayersKeys[j]).filePath.get();
-						exportLayer[currentLayersKeys[j]].clip = currentLayer.getChild(currentLayersKeys[j]).name;
-						exportLayer[currentLayersKeys[j]].startTime = currentLayer.getChild(currentLayersKeys[j]).startTime.get();
+				}
+			}
+			else if(tl_layers[i].getType()=="Audio"){
+				var keys = tl_layers[i].clips.getItems();
+				if(keys.length){
+					for(var j=0; j<keys.length; j++){
+						exportData.values.keys.layers[tl_layers[i].name][keys[j].name] = {filePath: keys[j].filePath.get(), startTime:keys[j].startTime.get()};
+
 					}
-					
 				}
 			}
+			
 		}
 	}
 
+
 	// exportData.groups
 	fileObj.writeFile(JSON.stringify(exportData), true);
 }
@@ -480,8 +519,10 @@ function moduleValueChanged(value){
 	if(!inibValuesChanged){
 		doSync = false;
 
-		script.log(value.getParent().name);
-
+		//script.log(value.getParent().name);
+		//here add actions for values that are also auto-updated, (groupKey values, times ets
+		// they will prevent auto update while manipulated manually
+		
 		doSync = true;
 	
 	}