Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 08-24-2015, 01:34 PM   #1
ovnis
Human being with feelings
 
ovnis's Avatar
 
Join Date: Oct 2011
Posts: 2,379
Default New script: Propagation of active takes color to all similarly named active takes

Select some items for local propagation. Don't select anything for general propagation.



https://stash.reaper.fm/v/24935/ovnis...ve%20takes.lua

Last edited by ovnis; 08-24-2015 at 04:21 PM.
ovnis is offline   Reply With Quote
Old 08-24-2015, 01:38 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 8,199
Default

Thanks for sharing your first script with us !
X-Raym is offline   Reply With Quote
Old 11-12-2020, 05:09 PM   #3
ovnis
Human being with feelings
 
ovnis's Avatar
 
Join Date: Oct 2011
Posts: 2,379
Default

Hello, little issue with "Propagation of active takes color to all similarly named active takes":

Quote:
...tive takes color to all similarly named active takes.lua:57: bad argument #1 to 'GetTakeName' (MediaItem_Take expected)
DO you know to avoid this?

Code:
function Main()
	--reaper.Undo_BeginBlock()
	selected_items_count=reaper.CountSelectedMediaItems(0)
	if selected_items_count~=0 then
		for j=0, selected_items_count-1 do
			item_selected=reaper.GetSelectedMediaItem(0, j)
			if item_selected~=nil then
				item_take_active_selected=reaper.GetActiveTake(item_selected)
				name_item_take_active_selected=reaper.GetTakeName(item_take_active_selected)
				color_item_take_active_selected=reaper.GetMediaItemTakeInfo_Value(item_take_active_selected, "I_CUSTOMCOLOR")
				items_count=reaper.CountMediaItems(0)
				for i=0, items_count-1 do
					item=reaper.GetMediaItem(0, i)
					if item~=item_selected then
						takes_count=reaper.CountTakes(item)
						for v=0, takes_count-1 do
							item_take=reaper.GetTake(item, v)
							if item_take~= nil then
								name_item_take=reaper.GetTakeName(item_take)
								if name_item_take==name_item_take_active_selected then 
									reaper.SetMediaItemTakeInfo_Value(item_take, "I_CUSTOMCOLOR", color_item_take_active_selected)
								end
							end
						end
					end
				end
			end
		end
	else
		items_count_source=reaper.CountMediaItems(0)
		for j=0, items_count_source-1 do
			item_source=reaper.GetMediaItem(0, j)
			if item_source~=nil then
				item_take_active_source=reaper.GetActiveTake(item_source)
				name_item_take_active_source=reaper.GetTakeName(item_take_active_source)
				color_item_take_active_source=reaper.GetMediaItemTakeInfo_Value(item_take_active_source, "I_CUSTOMCOLOR")
				items_count=reaper.CountMediaItems(0)
				for i=0, items_count-1 do
					item=reaper.GetMediaItem(0, i)
					if item~=item_source then
						takes_count=reaper.CountTakes(item)
						for v=0, takes_count-1 do
							item_take=reaper.GetTake(item, v)
							if item_take~= nil then
								name_item_take=reaper.GetTakeName(item_take)
								if name_item_take==name_item_take_active_source then 
									reaper.SetMediaItemTakeInfo_Value(item_take, "I_CUSTOMCOLOR", color_item_take_active_source)
								end
							end
						end
					end
				end
			end
		end
	end
--reaper.Undo_EndBlock("Propagation of active takes color to all similarly named active takes", -1)
end
reaper.PreventUIRefresh(1)
Main()
reaper.defer(Main)
reaper.UpdateArrange()
reaper.PreventUIRefresh(-1)
ovnis is offline   Reply With Quote
Old 11-12-2020, 05:25 PM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 8,199
Default

The original source code you uploaded on stash doesn't have this issue cause it do have the Take check before the take name funciton line 57


Code:
                item_take_active_source=reaper.GetActiveTake(item_source)
                if item_take_active_source then
                    name_item_take_active_source=reaper.GetTakeName(item_take_active_source)
(note this kind of check is needed twice in the script, one in first loop and one in second)


The error is within your posted scripted here, which doesn't seems to reflect what is on stash
X-Raym is offline   Reply With Quote
Old 11-12-2020, 05:51 PM   #5
ovnis
Human being with feelings
 
ovnis's Avatar
 
Join Date: Oct 2011
Posts: 2,379
Default

You are right! Thx you very much for your help!
ovnis is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:20 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.