Skip to content

Commit af241d0

Browse files
Landeplagecfillion
authored andcommitted
Release Insert new track (inherit color from parent) v1.0 (ReaTeam#182)
1 parent ada8512 commit af241d0

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
-- @description Insert new track (inherit color from parent)
2+
-- @author Mordi
3+
-- @version 1.0
4+
-- @about
5+
-- # Insert new track (inherit color from parent)
6+
--
7+
-- Uses reaper's native "Insert new track" action, and colors the new track based on its parent track. If the track has no parent, no color will be applied.
8+
9+
SCRIPT_NAME = "Insert new track (inherit color from parent)"
10+
11+
-- Message function
12+
function Msg(str)
13+
reaper.ShowConsoleMsg(tostring(str) .. "\n")
14+
end
15+
16+
-- Begin undo-block
17+
reaper.Undo_BeginBlock2(0)
18+
19+
-- Add new track
20+
reaper.Main_OnCommand(40001, 0)
21+
22+
-- Get number of selected tracks
23+
selNum = reaper.CountSelectedTracks(0)
24+
25+
-- Loop through each selected track
26+
for i = 1, selNum do
27+
28+
-- Get selected track
29+
track = reaper.GetSelectedTrack(0, i-1)
30+
31+
-- Get parent track
32+
parent = reaper.GetMediaTrackInfo_Value(track, "P_PARTRACK")
33+
34+
-- Skip if track has no parent
35+
if parent ~= 0.0 then
36+
37+
-- Get color from parent track
38+
color = reaper.GetTrackColor(parent)
39+
40+
-- Apply color to selected track
41+
reaper.SetTrackColor(track, color)
42+
43+
end
44+
end
45+
46+
-- End undo-block
47+
reaper.Undo_EndBlock2(0,SCRIPT_NAME,-1)

0 commit comments

Comments
 (0)