Old 08-05-2020, 12:01 PM   #1
sw_
Human being with feelings
 
Join Date: Oct 2018
Posts: 50
Default Select all items on one side of the cursor

Would it be possible to select all items on one side of the edit cursor? So if I place the cursor in the middle of a project I could select everything on the right side... or the left side. Is that something that could be done in Lua?
sw_ is offline   Reply With Quote
Old 08-05-2020, 12:40 PM   #2
Yanick
Human being with feelings
 
Yanick's Avatar
 
Join Date: May 2018
Location: Moscow, Russia
Posts: 262
Default

Yes you can. The "right" version
PHP Code:
reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()


local count reaper.CountMediaItems(0)
local cur_pos reaper.GetCursorPosition()
reaper.Main_OnCommand(40289,0)

for 
0count-do
  
item reaper.GetMediaItem(0i)
  
info reaper.GetMediaItemInfo_Value(item'D_POSITION')
  if 
info >= cur_pos then
    reaper
.SetMediaItemSelected(item1)
  
end
end


reaper
.UpdateArrange()
reaper.Undo_EndBlock("Select all items right of edit cursor", -1)
reaper.PreventUIRefresh(-1
For the "left" version, change >= to < in the loop and change the undo name to "Select all items left of edit cursor", but it will also select the items that the edit cursor passes through
__________________
My scripts for rendering

Last edited by Yanick; 08-06-2020 at 09:28 AM.
Yanick is offline   Reply With Quote
Old 08-05-2020, 12:55 PM   #3
Yanick
Human being with feelings
 
Yanick's Avatar
 
Join Date: May 2018
Location: Moscow, Russia
Posts: 262
Default

Or, so that the "right" version selects the items through which the edit cursor passes, do like this
PHP Code:
reaper.PreventUIRefresh(1)
reaper.Undo_BeginBlock()


local count reaper.CountMediaItems(0)
local cur_pos reaper.GetCursorPosition()
reaper.Main_OnCommand(40289,0)

for 
0count-do
  
item reaper.GetMediaItem(0i)
  
start reaper.GetMediaItemInfo_Value(item'D_POSITION')
  
info start reaper.GetMediaItemInfo_Value(item'D_LENGTH'
  if 
info cur_pos then
    reaper
.SetMediaItemSelected(item1)
  
end
end


reaper
.UpdateArrange()
reaper.Undo_EndBlock("Select all items right of edit cursor", -1)
reaper.PreventUIRefresh(-1
Accordingly, for the "left" version, change > to <= in the loop and then this script will not select items through which the edit cursor passes
__________________
My scripts for rendering

Last edited by Yanick; 08-06-2020 at 09:28 AM.
Yanick is offline   Reply With Quote
Old 08-05-2020, 03:31 PM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,747
Default

THis stuff already exists and is made by przemoc, in https://github.com/przemoc/REAPER-ReaScripts,



the reapack link is available on reapack.com.
X-Raym is offline   Reply With Quote
Old 08-06-2020, 03:58 AM   #5
sw_
Human being with feelings
 
Join Date: Oct 2018
Posts: 50
Default

[QUOTE=X-Raym;2328575]THis stuff already exists and is made by przemoc, in https://github.com/przemoc/REAPER-ReaScripts,

I tried Przemoc's script but I thought it lacked some of the features I needed, do be able to include/exclude overlapping items. So I used on of your scripts as a foundation, modified it and expanded it into these.

https://github.com/bjornlohmander/Re...ct-From-Cursor
sw_ is offline   Reply With Quote
Old 08-06-2020, 05:42 AM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,747
Default

Thx for sharing :P
X-Raym is offline   Reply With Quote
Old 08-06-2020, 11:03 AM   #7
PelF
Human being with feelings
 
PelF's Avatar
 
Join Date: Mar 2013
Posts: 107
Default

I use these scripts (but in .eel)
PelF 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:03 PM.


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