Browse Source

don't import file if sequence is undefined

eLandon 4 years ago
parent
commit
555c054e45
1 changed files with 60 additions and 56 deletions
  1. 60 56
      SequenceMgr.js

+ 60 - 56
SequenceMgr.js

@@ -246,74 +246,78 @@ function importSequenceFile(loadFile){
 	parameters.syncRate.set(loadData.parameters.SyncRate);
 	parameters.synchronize.set(loadData.parameters.Synchronize);
 	sequence = loadData.parameters.Sequence;
-	parameters.sequence.removeOptions();
-	parameters.sequence.addOption(sequence,0);
-	parameters.sequence.setAttribute("readonly", true);
-	// script.log(parameters.synchronize.get());
-	// 
-	//check if Sequence already exists in sequences manager, else create it
-	var tl_sequence = root.sequences.getItemWithName(sequence) ;
-	if(tl_sequence == undefined){
-		tl_sequence = root.sequences.addItem();
-		tl_sequence.setName(sequence);
-	}
+	if(sequence!="undefined"){
+
+		parameters.sequence.removeOptions();
+		parameters.sequence.addOption(sequence,0);
+		parameters.sequence.setAttribute("readonly", true);
+		// script.log(parameters.synchronize.get());
+		// 
+		//check if Sequence already exists in sequences manager, else create it
+		var tl_sequence = root.sequences.getItemWithName(sequence) ;
+		if(tl_sequence == undefined){
+			tl_sequence = root.sequences.addItem();
+			tl_sequence.setName(sequence);
+		}
 
-	//recreate cues
-	tl_sequence.cues.removeAll();
-	var cuesList = util.getObjectProperties(loadData.values.keys.cues, true, false);
-	if(cuesList.length){
-		for(var i=0; i<cuesList.length; i++){
-			var cue = tl_sequence.cues.addItem();
-			cue.setName(cuesList[i]);
-			cue.time.set(loadData.values.keys.cues[cuesList[i]].time);
+		//recreate cues
+		tl_sequence.cues.removeAll();
+		var cuesList = util.getObjectProperties(loadData.values.keys.cues, true, false);
+		if(cuesList.length){
+			for(var i=0; i<cuesList.length; i++){
+				var cue = tl_sequence.cues.addItem();
+				cue.setName(cuesList[i]);
+				cue.time.set(loadData.values.keys.cues[cuesList[i]].time);
+			}
 		}
-	}
 
-	//recreate layers and keys
-	tl_sequence.layers.removeAll();
-	var layersList = util.getObjectProperties(loadData.values.keys.layers, true, false);
-	if(layersList.length){
-		for(var i=0; i<layersList.length; i++ ){
-			var layer = tl_sequence.layers.addItem("Mapping");
-			layer.setName(layersList[i]);
-			var keysList = util.getObjectProperties(loadData.values.keys.layers[layersList[i]], true, false);
-			if(keysList.length){
-				for(var j=0; j<keysList.length; j++){
-					var key = layer.automation.addItem();
-					key.setName(keysList[j]);
-					key.value.set(loadData.values.keys.layers[layersList[i]][keysList[j]].value);
-					key.position.set(loadData.values.keys.layers[layersList[i]][keysList[j]].time);
+		//recreate layers and keys
+		tl_sequence.layers.removeAll();
+		var layersList = util.getObjectProperties(loadData.values.keys.layers, true, false);
+		if(layersList.length){
+			for(var i=0; i<layersList.length; i++ ){
+				var layer = tl_sequence.layers.addItem("Mapping");
+				layer.setName(layersList[i]);
+				var keysList = util.getObjectProperties(loadData.values.keys.layers[layersList[i]], true, false);
+				if(keysList.length){
+					for(var j=0; j<keysList.length; j++){
+						var key = layer.automation.addItem();
+						key.setName(keysList[j]);
+						key.value.set(loadData.values.keys.layers[layersList[i]][keysList[j]].value);
+						key.position.set(loadData.values.keys.layers[layersList[i]][keysList[j]].time);
+					}
 				}
+				layer.automation.reorderItems();
 			}
-			layer.automation.reorderItems();
 		}
-	}
 
-	//recreate groups
-	var groupList = util.getObjectProperties(loadData.values.groups, true, false);
-	if(groupList.length){
-		for(var i=0; i<groupList.length; i++){
-			var group = local.getChild("Values").groups.addContainer(groupList[i]);
-			var groupLayers = util.getObjectProperties(loadData.values.groups[groupList[i]], true, false);
-			group.addFloatParameter("cue", "", 0., 0.);
-			group.setName(groupList[i]);
-			group.cue.set(loadData.values.groups[groupList[i]].time);
-
-			var groupKeysList = util.getObjectProperties(loadData.values.groups[groupList[i]].groupKeys, true, false);
-			if (groupKeysList.length){
-				var keysContainer = group.addContainer("keys");
-				keysContainer.setCollapsed(true);
-				for (var j=0; j<groupKeysList.length; j++){
-					group.addFloatParameter(groupKeysList[j], "", 0., 0., 1.);
-					keysContainer.addStringParameter(groupKeysList[j], "", loadData.values.groups[groupList[i]]['groupKeys'][groupKeysList[j]]['key']);
+		//recreate groups
+		var groupList = util.getObjectProperties(loadData.values.groups, true, false);
+		if(groupList.length){
+			for(var i=0; i<groupList.length; i++){
+				var group = local.getChild("Values").groups.addContainer(groupList[i]);
+				var groupLayers = util.getObjectProperties(loadData.values.groups[groupList[i]], true, false);
+				var cue = group.addFloatParameter("cue", "", 0., 0.);
+				group.setName(groupList[i]);
+				cue.set(loadData.values.groups[groupList[i]].time);
+
+				var groupKeysList = util.getObjectProperties(loadData.values.groups[groupList[i]].groupKeys, true, false);
+				if (groupKeysList.length){
+					var keysContainer = group.addContainer("keys");
+					keysContainer.setCollapsed(true);
+					for (var j=0; j<groupKeysList.length; j++){
+						group.addFloatParameter(groupKeysList[j], "", 0., 0., 1.);
+						keysContainer.addStringParameter(groupKeysList[j], "", loadData.values.groups[groupList[i]]['groupKeys'][groupKeysList[j]]['key']);
+					}
 				}
 			}
 		}
+
+		// script.log(layersList[0]);
+		doSync = true;
+		// updateSynchronize() ;
 	}
 
-	// script.log(layersList[0]);
-	doSync = true;
-	// updateSynchronize() ;
 
 }