https://github.com/OSBooter/Tracktion-WF-Macros/issues
I reached a timeout issue, I've encapsulated some code in a for loop and it would crash the js interpreter :/
But when I explicitly declare the reiterated code with filled integers instead of the for loop it runs fine :/
Is it just me or a logic error :/
Anyways, it's sorta off topic but a macro fix request ;d
see line 33
Code: Select all
//selAllMarkedRegion();
function selAllMarkedRegion() {
/**
Name:All Marked Region Clip Select [Theoretically Should Work]
Description:Selects all clips from the edit in the marked region, it must start in the marked region,
endings don't count.
Author:Andrew Cheung
Version:V1
Changelog:
-there is a for loop bug that won't allow the code to be handled...
-it should theoretically work but it doesn't
**/
//Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.//selects all clips in between the in/out markers
//affects the in/out markers
//
////saves state for markers and cursors
var curPos = Tracktion.getPosition ('cursor');
var markInPos = Tracktion.getPosition ('markIn');
var markOutPos = Tracktion.getPosition ('markOut');
var curClips = Tracktion.getSelectedEditElements ('clip');
//insert code here
//Tracktion.selectItem ('none');//do not select all after selecting none as that will lead to a loss of focus
var allTracks = getAllTracks();
var curTrackClips;
var markedClips;
var markedClipsCollection;
var trackCount = allTracks.length;
for (i = 0; i < trackCount; i++){
curTrackClips = Tracktion.getClipsFromTracks (allTracks[i]);
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (curTrackClips[0]);//gets selMarkedRegion a cliptrack
selMarkedRegion();//may mark nothing
markedClips = Tracktion.getSelectedEditElements ('clip');
Tracktion.addObjectsToSelection (markedClipsCollection);
markedClipsCollection = Tracktion.getSelectedEditElements ('clip');
}
//code end
//reset changes to markers and cursors
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (markedClipsCollection);//if you select some stuff and haven't deleted any clips use this to default
Tracktion.setPosition ('cursor', curPos);
Tracktion.setPosition ('markIn', markInPos);
Tracktion.setPosition ('markOut', markOutPos);
}
//functions
function getAllTracks (){
/**
Name:Get All Tracks
Description:gets an array of tracks from the edit
Author:Andrew Cheung
Version:V1
**/
//Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.
var curPos = Tracktion.getPosition ('cursor');
var markInPos = Tracktion.getPosition ('markIn');
var markOutPos = Tracktion.getPosition ('markOut');
var curClips = Tracktion.getSelectedEditElements ('clip');
//insert code here
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (Tracktion.getEditElements ('track'));
var allTracks;
allTracks = Tracktion.getSelectedEditElements ('track');
//code end
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (curClips);//if you select some stuff and haven't deleted any clips use this to default
Tracktion.setPosition ('cursor', curPos);
Tracktion.setPosition ('markIn', markInPos);
Tracktion.setPosition ('markOut', markOutPos);
return allTracks;
}
function selMarkedRegion() {
/**
Name:Marked Region Clip Select
Description:Selects a clip that starts in the marked region. If you have selected all the clips in the track
The selected track will be from the first track because of Tracktion logic.
Author:Andrew Cheung
Version:V4
Changelog:
+fixed bug where selectItem jumps to another track when there is only 1 clip in the track.
+changed workaround to proper logic using getClipsFromTracks instead of getSelectedEditElements.
+fixed can't deal with the last clip
**/
//Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.//selects all clips in between the in/out markers
//affects the in/out markers
//
////saves state for markers and cursors
var curPos = Tracktion.getPosition ('cursor');
var markInPos = Tracktion.getPosition ('markIn');
var markOutPos = Tracktion.getPosition ('markOut');
var curClips = Tracktion.getSelectedEditElements ('clip');
//insert code here
//Tracktion.selectItem ('none');//do not select all after selecting none as that will lead to a loss of focus
var markedClips;// = Tracktion.getSelectedEditElements ('clip');
var trackObject = Tracktion.getTrackFromSelectedObject();
var trackClips = Tracktion.getClipsFromTracks (trackObject);
var trackClipCount = trackClips.length;
var firstClip;
var lastClip;
var clipMarkInPos;
var clipMarkOutPos;
var temp;
var i;
for (i = 0; i < trackClipCount; i++) {// for each clip
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (trackClips[i]);//grab positions to check if it is in marked area
// temp = Tracktion.getSelectedEditElements ('clip');//holds the current indexed object
Tracktion.markAroundSelected();
clipMarkInPos = Tracktion.getPosition ('markIn');
clipMarkOutPos = Tracktion.getPosition ('markOut');
if (markInPos <= clipMarkInPos && clipMarkInPos < markOutPos){//
Tracktion.addObjectsToSelection (markedClips);
markedClips = Tracktion.getSelectedEditElements ('clip');//puts the clip into the marked clip list
//break;
}
}
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (markedClips);
//code end
//reset changes to markers and cursors
//Tracktion.addObjectsToSelection (curClips);//if you select some stuff and haven't deleted any clips use this to default
Tracktion.setPosition ('cursor', curPos);
Tracktion.setPosition ('markIn', markInPos);
Tracktion.setPosition ('markOut', markOutPos);
}
Code: Select all
selAllMarkedRegion();
function selAllMarkedRegion() {
/**
Name:All Marked Region Clip Select [Prectically Should Work]
Description:Selects all clips from the edit in the marked region, it must start in the marked region,
endings don't count.
Author:Andrew Cheung
Version:V1
Changelog:
-there is a for loop bug that won't allow the code to be handled...
-it should theoretically work but it doesn't
**/
//Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.//selects all clips in between the in/out markers
//affects the in/out markers
//
////saves state for markers and cursors
var curPos = Tracktion.getPosition ('cursor');
var markInPos = Tracktion.getPosition ('markIn');
var markOutPos = Tracktion.getPosition ('markOut');
var curClips = Tracktion.getSelectedEditElements ('clip');
//insert code here
//Tracktion.selectItem ('none');//do not select all after selecting none as that will lead to a loss of focus
var allTracks = getAllTracks();
var curTrackClips;
var markedClips;
var markedClipsCollection;
var trackCount = allTracks.length;
// for (i = 0; i < trackCount; i++){
//loop one would go
curTrackClips = Tracktion.getClipsFromTracks (allTracks[0]);
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (curTrackClips[0]);//gets selMarkedRegion a cliptrack
selMarkedRegion();//may mark nothing
markedClips = Tracktion.getSelectedEditElements ('clip');
Tracktion.addObjectsToSelection (markedClipsCollection);
markedClipsCollection = Tracktion.getSelectedEditElements ('clip');
//loop two would go
curTrackClips = Tracktion.getClipsFromTracks (allTracks[1]);
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (curTrackClips[0]);//gets selMarkedRegion a cliptrack
selMarkedRegion();//may mark nothing
markedClips = Tracktion.getSelectedEditElements ('clip');
Tracktion.addObjectsToSelection (markedClipsCollection);
markedClipsCollection = Tracktion.getSelectedEditElements ('clip');
// }
//code end
//reset changes to markers and cursors
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (markedClipsCollection);//if you select some stuff and haven't deleted any clips use this to default
Tracktion.setPosition ('cursor', curPos);
Tracktion.setPosition ('markIn', markInPos);
Tracktion.setPosition ('markOut', markOutPos);
}
//functions
function getAllTracks (){
/**
Name:Get All Tracks
Description:gets an array of tracks from the edit
Author:Andrew Cheung
Version:V1
**/
//Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.
var curPos = Tracktion.getPosition ('cursor');
var markInPos = Tracktion.getPosition ('markIn');
var markOutPos = Tracktion.getPosition ('markOut');
var curClips = Tracktion.getSelectedEditElements ('clip');
//insert code here
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (Tracktion.getEditElements ('track'));
var allTracks;
allTracks = Tracktion.getSelectedEditElements ('track');
//code end
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (curClips);//if you select some stuff and haven't deleted any clips use this to default
Tracktion.setPosition ('cursor', curPos);
Tracktion.setPosition ('markIn', markInPos);
Tracktion.setPosition ('markOut', markOutPos);
return allTracks;
}
function selMarkedRegion() {
/**
Name:Marked Region Clip Select
Description:Selects a clip that starts in the marked region. If you have selected all the clips in the track
The selected track will be from the first track because of Tracktion logic.
Author:Andrew Cheung
Version:V4
Changelog:
+fixed bug where selectItem jumps to another track when there is only 1 clip in the track.
+changed workaround to proper logic using getClipsFromTracks instead of getSelectedEditElements.
+fixed can't deal with the last clip
**/
//Tip: Don't Select None Without keeping a focusable object or there will be a freeze state.//selects all clips in between the in/out markers
//affects the in/out markers
//
////saves state for markers and cursors
var curPos = Tracktion.getPosition ('cursor');
var markInPos = Tracktion.getPosition ('markIn');
var markOutPos = Tracktion.getPosition ('markOut');
var curClips = Tracktion.getSelectedEditElements ('clip');
//insert code here
//Tracktion.selectItem ('none');//do not select all after selecting none as that will lead to a loss of focus
var markedClips;// = Tracktion.getSelectedEditElements ('clip');
var trackObject = Tracktion.getTrackFromSelectedObject();
var trackClips = Tracktion.getClipsFromTracks (trackObject);
var trackClipCount = trackClips.length;
var firstClip;
var lastClip;
var clipMarkInPos;
var clipMarkOutPos;
var temp;
var i;
for (i = 0; i < trackClipCount; i++) {// for each clip
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (trackClips[i]);//grab positions to check if it is in marked area
// temp = Tracktion.getSelectedEditElements ('clip');//holds the current indexed object
Tracktion.markAroundSelected();
clipMarkInPos = Tracktion.getPosition ('markIn');
clipMarkOutPos = Tracktion.getPosition ('markOut');
if (markInPos <= clipMarkInPos && clipMarkInPos < markOutPos){//
Tracktion.addObjectsToSelection (markedClips);
markedClips = Tracktion.getSelectedEditElements ('clip');//puts the clip into the marked clip list
//break;
}
}
Tracktion.selectItem ('none');
Tracktion.addObjectsToSelection (markedClips);
//code end
//reset changes to markers and cursors
//Tracktion.addObjectsToSelection (curClips);//if you select some stuff and haven't deleted any clips use this to default
Tracktion.setPosition ('cursor', curPos);
Tracktion.setPosition ('markIn', markInPos);
Tracktion.setPosition ('markOut', markOutPos);
}
