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

Reply
 
Thread Tools Display Modes
Old 08-09-2018, 05:46 PM   #1
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default 2 New Scripts: Smart Vertical selection w/ previous selection aware

Hi guys, (are there any women in this forum?)

Here are 2 new scripts I wrote to suit some of my editing needs... especially since Arming Action Icons with Key Commands will be officially supported soon. These basically turn your mouse into a smart selection tool. There are similar scripts out there but when using Snap there can be issues in selecting the correct items and they are problematic for multi selecting (Clicking new items etc). Snap should not inhibit this script and neither should previously selected items be affected.

Script #1: Select_All_Items_Under_Cursor_All_Tracks
  • Click on any item and all items crossing cursor vertically above and below will be selected.
  • Previous selection will be retained allowing multiple vertical selections -- even from previously marqueed selections.


Script #1: Select_Items_Under_Cursor_on Selected Tracks
  • Click on any item and ONLY items on selected tracks crossing cursor vertically above and below will be selected.
  • Previous selection will be retained allowing multiple vertical selections -- even from previously marqueed selections.

With both of these scripts, I bound them to a Toolbar Icon that will be Key Command-able very soon. But the functionality
Hope you find it useful. Let me know if you find any odd behaviors.

Script #1: Select_All_Items_Under_Cursor_All_Tracks




Script #1: Select_Items_Under_Cursor_On_Selected_Tracks



Select All Items Under Cursor on ALL Tracks
Code:
--   written by Thonex aka Andrew K  
        
function Select_All_Items_Under_Cursor_All_Tracks ()

  reaper.PreventUIRefresh(1)
  reaper.ClearConsole() 
  reaper.Undo_BeginBlock()
  
  Cur_Pos = reaper.BR_PositionAtMouseCursor( true )
  
  Num_Sel_1 = reaper.CountSelectedMediaItems(0 )
  
  t_Prev_Sel_ID = {}

  for i=0,  Num_Sel_1 -1 do -- scans already selected PLUS the clicked item (clicked item will be first ID)
     t_Prev_Sel_ID[i] = reaper.GetSelectedMediaItem(0,i)  
  end

  local L_Start, R_End = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false) -- Get TimeSelection from orig position
  local _, __ = reaper.GetSet_LoopTimeRange(true, false, Cur_Pos-.001, Cur_Pos+.001, false) -- Set TimeSelection 1 ms to right and left of mouse click
  reaper.Main_OnCommand( 40717, 0)  -- Item: Select all items in current time selection

  for i=0,  Num_Sel_1 -1 do
    reaper.SetMediaItemSelected( t_Prev_Sel_ID[i], 1 ) 
  end

  local _, __ = reaper.GetSet_LoopTimeRange(true, false, L_Start, R_End, false) -- Set TimeSelection

  reaper.PreventUIRefresh(-1)
  reaper.UpdateArrange()
  reaper.Undo_EndBlock("Select all items under cursor",-1)

end 
 Select_All_Items_Under_Cursor_All_Tracks ()
Select All Items Under Cursor On Selected Tracks
Code:
-- written by Thonex aka Andrew K

function itemUnderMouse()
  reaper.BR_GetMouseCursorContext()
  return reaper.BR_GetMouseCursorContext_Item()
end


function Select_All_Items_Under_Cursor_On_Selected_Tracks()

  reaper.PreventUIRefresh(1)
  reaper.ClearConsole() 
  reaper.Undo_BeginBlock()
  
  
  local Clicked_Item = itemUnderMouse()
  if Clicked_Item ~= nil then
      reaper.SetMediaItemSelected(Clicked_Item, 0 )
  end
  
  Cur_Pos = reaper.BR_PositionAtMouseCursor( true )

  Num_Sel_1 = reaper.CountSelectedMediaItems(0 )
  
  t_Prev_Sel_ID = {}

  for i=0,  Num_Sel_1 -1 do -- scans already selected items
     t_Prev_Sel_ID[i] = reaper.GetSelectedMediaItem(0,i)  
  end
  

  local L_Start, R_End = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false) -- Get Time Selection initial pos
  local _, __ = reaper.GetSet_LoopTimeRange(true, false, Cur_Pos-.001, Cur_Pos+.001, false) -- Set TimeSelection 1 ms to right and left of mouse click
  reaper.Main_OnCommand( 40718, 0) -- Item: Select all items on selected tracks in current time selection

   for i=0,  Num_Sel_1 -1 do -- reselct all previous items
      reaper.SetMediaItemSelected( t_Prev_Sel_ID[i], 1 )   
   end

  local _, __ = reaper.GetSet_LoopTimeRange(true, false, L_Start, R_End, false) -- Set Time Selection to initial pos

  reaper.PreventUIRefresh(-1)
  reaper.UpdateArrange()
  reaper.Undo_EndBlock("Select all items under cursor",-1)

end 

Select_All_Items_Under_Cursor_On_Selected_Tracks()
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.

Last edited by Thonex; 08-12-2018 at 11:38 AM. Reason: removed an unnecessary line of code
Thonex is offline   Reply With Quote
Old 08-10-2018, 05:32 AM   #2
Ivannn Bennnettt
Human being with feelings
 
Join Date: Feb 2017
Posts: 305
Default

Thank you for sharing
Are you seeking girlfrend?
Ivannn Bennnettt is offline   Reply With Quote
Old 08-10-2018, 06:39 AM   #3
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Wow, awesome man! Checking them out
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is online now   Reply With Quote
Old 08-10-2018, 09:35 AM   #4
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Just tried the scripts and there's a tiny little typo in the last line of the first script.
It points to the wrong function. It needs to be changed to:

Select_All_Items_Under_Cursor_All_Tracks ()
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is online now   Reply With Quote
Old 08-10-2018, 10:13 AM   #5
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by _Stevie_ View Post
Just tried the scripts and there's a tiny little typo in the last line of the first script.
It points to the wrong function. It needs to be changed to:

Select_All_Items_Under_Cursor_All_Tracks ()
That's what happens when I copy from Sublime instead of the Reascript API. All fixed. Thanks man.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.

Last edited by Thonex; 08-10-2018 at 10:22 AM.
Thonex is offline   Reply With Quote
Old 08-10-2018, 10:24 AM   #6
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by Ivannn Bennnettt View Post
Thank you for sharing
Are you seeking girlfrend?
LOL.... no, I'm relatively new here... and I don't remember seeing any women in this forum. So was just curious after I wrote... "Hey Guys"
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 08-11-2018, 02:21 AM   #7
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

Thonex, awesome scripts !

Any chance of adding these to ReaPack plz ?
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 08-11-2018, 03:54 AM   #8
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by vanhaze View Post
Thonex, awesome scripts !

Any chance of adding these to ReaPack plz ?

Yeah... I think so. I just want to make sure I use them some more to check for edge-case errors. So far all has been good.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 08-11-2018, 12:23 PM   #9
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

Superb !
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 08-15-2018, 07:45 AM   #10
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 15,618
Default

Really nice... many thanks... please keep writing!
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva
hopi 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 05:51 PM.


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