Re-Posting in Main Forum in hopes of feedback: Macro help?

Discussion about: tracktion.com
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi all.

I posted this in the "macros" sticky, but I'm not sure anyone saw it....

I'm trying to create two macros:

1- After selecting any clip on a track, I can invoke the macro to select all following clips on the same track

2 - After selecting any clip on a track, I can invoke the macro to select all following clips on all tracks. (It doesn't matter if clips on other tracks that occur at the same time as the initial chosen clip are selected or not ... as long as the behavior is consistent.)

In either case, at the end of the process, the view/zoom level of the project would not have changed.

So, for macro #1, this code will select ALL clips on a track, but I don't know how to give it directionality and selectivity.

Code: Select all

var track = Tracktion.getTrackFromSelectedObject();
var clips = Tracktion.getClipsFromTracks (track);
var position = Tracktion.getPosition (selected);
Tracktion.addObjectsToSelection (clips);
This next piece of code is adapted from other code found here or in the API. It tests whether or not a clip follows AFTER the starting clip and then supposedly selects it, but I couldn't get anything but the last clip on the track to remain selected at the end of the process.

Code: Select all

//SELECT FOLLOWING CLIPS

var track = Tracktion.getTrackFromSelectedObject();
var clips = Tracktion.getClipsFromTracks (track);
var position = Tracktion.getPosition (selected);

var minSeparation = 0.1;
var newPosition = 36000;

for (var i = 0; i < clips.length; ++i)
{
	var clipStart = parseFloat (clips[i].getProperty ('start'));

    	if (clipStart > position && clipStart < newPosition)
        	if (clipStart > (position + minSeparation))
        		Tracktion.addObjectsToSelection (clip[i]);
            		Tracktion.selectItem ('right');
            		newPosition = clipStart;
}

if (newPosition != 36000)
{
    Tracktion.setPosition ('transport', position);
    Tracktion.setViewBoundsAroundTime (position, 0.6);
}
I imagine macro #2 would build on a working version of this, but with an additional iterative level to determine how many tracks there are with clips, and then selecting all clips on each track that occur after the clip initially picked...? (My coding days are long passed me I'm afraid.)

Anyway, if anyone has a moment and is willing, I'd appreciate any insights. Thank you.
iMacPro 1,1 | 64gb | OSX 10.15.7
http://www.gesslr.com
http://www.storyaudio.com

Post

*bump*

Anyone? Anyone? 1812? Bueller...?
iMacPro 1,1 | 64gb | OSX 10.15.7
http://www.gesslr.com
http://www.storyaudio.com

Post

From the API

selectItem() : Selects an item relative to the currently selected one
addObjectsToSelection() : Add objects to selection. Adds an object to the current selection. This may deselect other objects if they can't be selected at the same time.

In the example code above I think your use of selectItem() before addObjectsToSelection() is resetting the selection to one single item first, each time through the loop, before you add to the selection.

So instead of the selection being

item1
item 1, item 2,
item1, item2, item3

its

item1
item2
item3
An idiot on Set Theory:
"In some cases there is an object called red that contains everything that is red. In much the same way a pot is a plate."

Post Reply

Return to “Tracktion”