Old 07-10-2019, 11:27 AM   #1
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 1,627
Default select an item by its name?

me2beats has a script called 'me2beats_Select take (by name).lua' that sounds like it does what i want but actually sets the active take rather than selecting the item.

is there an action or script that will ask for input of a take name and then select the item with that name?

until now i've been using regions to search for specific items (i've set a region for each of the items i might want to find). it would be more direct, though, to be able to search for and select an item based on its take name. is there a way to do that?

thanks,
babag
(almost finished setting up this workflow, i promise.)
babag is offline   Reply With Quote
Old 07-10-2019, 12:48 PM   #2
Nostrap
Human being with feelings
 
Join Date: Dec 2017
Posts: 81
Default

This would be an easy script to make, but honestly I would just use the Project Bay for this. You can filter the Media Items tab and very quickly find the item you want
Nostrap is offline   Reply With Quote
Old 07-10-2019, 01:17 PM   #3
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 1,627
Default

yeah, but i'm ultimately trying to make toolbar buttons to perform actions with these selections. would add a lot of steps to have to go to the project bay in the middle of things. much faster to just click a button and it selects a predefined item, then performs the actions as opposed to going to the project bay (which would mean a focus change), filtering, selecting. then performing the actions.

thanks,
babag
babag is offline   Reply With Quote
Old 07-10-2019, 02:16 PM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,919
Default

I already made that....


Look for Find or Search keywords in action list !
X-Raym is offline   Reply With Quote
Old 07-10-2019, 02:25 PM   #5
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 1,627
Default

thanks! will do.
babag is offline   Reply With Quote
Old 07-10-2019, 04:03 PM   #6
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 1,627
Default

found this so far:

Items Properties/X-Raym_Search_and_replace_in_selected_active_takes_n ames.lua

is there a way to restrict this to searching the selected track? looks like it searches all tracks. (i don't know much about this kind of thing so i could be very wrong about that.) can i do that by selecting only the items on the selected track? there are native actions for that that i could make use of.

also, will test this when i get in front of reaper but, does this select the item when it finds it? wasn't sure from looking at the code. really bad at that here. actually, now that i look at it, it seems to work on selected items. wouldn't that be a problem if i want to use the script to make a selection and it's already selected?

will continue looking. looking at this:

X-Raym_Find and go to next items on selected tracks with input text as notes.lua

both seem like they require lots of editing to get them down to the simplicity i was looking for but maybe the second is better.

thanks,
babag

Last edited by babag; 07-10-2019 at 04:18 PM.
babag is offline   Reply With Quote
Old 07-10-2019, 06:17 PM   #7
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,919
Default

Oh you are right X-Raym_Find and go to next items on selected tracks with input text as notes.lua is the script I was thinking about, but it is item notes, and only selected tracks.


I was prettu sure there was another scripts to just select all items with a active take name containing X but I dont find it either so maybe it has to be written too.
X-Raym is offline   Reply With Quote
Old 07-10-2019, 08:07 PM   #8
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 1,627
Default

yeah. thanks. been trying to figure it out and, while i pretty much get the general logic of it, coding syntax just always looks like martian to me. can't figure it out at all.

thanks,
babag
babag is offline   Reply With Quote
Old 07-11-2019, 12:37 AM   #9
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 117
Default

Quote:
Originally Posted by babag View Post
yeah. thanks. been trying to figure it out and, while i pretty much get the general logic of it, coding syntax just always looks like martian to me. can't figure it out at all.

thanks,
babag
I've actually just been requested to add a search-bar to my Item Reader script.

Would that be something that would interest you, or are you specifically wanting a feature to search takes and not items?
Dafarkias is offline   Reply With Quote
Old 07-11-2019, 03:55 AM   #10
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,919
Default

@babag
Just added

  • Script: X-Raym_Select items by active take name input.lua



to my Item selection pack premium scripts.





Hope it solve the issue :P
X-Raym is offline   Reply With Quote
Old 07-11-2019, 09:05 PM   #11
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 1,627
Default

thanks, dafarkias, but i think i want something much simpler as a standalone that i can add together with other simple actions to make a custom action. i appreciate your asking, though.

thanks, x. this appears to work on all track. i was looking for something that would work on a single selected track. i was planning on combining it with actions to:

1. unselect all tracks
2. select a specific track, in my case 3
3. this script

i did find a script from Archie that i was able to make some changes to and have gotten to work. it needs work but as a preliminary test it does work.
Code:
    -----------------------------------------------------------------------------
    local function No_Undo()end; local function no_undo()reaper.defer(No_Undo)end
    -----------------------------------------------------------------------------
     
    local SelTrack = reaper.GetSelectedTrack( 0, 0 )
    if not SelTrack then no_undo() return end
    
    local CountTrItem = reaper.CountTrackMediaItems( SelTrack )
    if CountTrItem > 0 then
        local Name = "test"
        for i = 1,CountTrItem do 
            local Tr_item =  reaper.GetTrackMediaItem( SelTrack, i-1 )
            local Take = reaper.GetActiveTake( Tr_item )
            if Take ~= nil then
              local Take_Name = reaper.GetTakeName( Take )
            
              if Take_Name == Name then
                  reaper.SelectAllMediaItems( 0, 0 )
                  reaper.SetMediaItemSelected( Tr_item, 1 )
                  undo = 1
                  break
              end
            end       
        end
    end 
    
    if undo == 1 then 
        reaper.Undo_BeginBlock()   
        reaper.Undo_EndBlock( [[Select first item from cursor
                             position in first selected track]],-1)
    else   
        no_undo()
    end
since this is intended to work with a template and stock items, the item names would be standardized and i thought i would hard-code them into the script. here it's just called 'test' but i thought i would make a new script for each of the roughly 20 stock items, each with its own name coded in. it will make things much faster in this context than having to take user input each time the stock item is sought. i do want to make a version that asks for user input but just as a variation.

maybe someone could confirm that i haven't done anything horrible in the changes?

thanks,
babag

Last edited by babag; 07-11-2019 at 09:16 PM.
babag is offline   Reply With Quote
Old 07-11-2019, 09:43 PM   #12
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 1,627
Default

this seems to work for a version with user input. i'm pretty sure there must be something screwy with the coding, though, as i have little idea at all what i'm doing. it does seem to work, though:
Code:
-- GET USER INPUT
retval, search = reaper.GetUserInputs("Find and Go", 1, "Search (% for escape char)", "")

if retval then -- if user complete the fields
  if search ~= nil and search ~= "" then
    reaper.PreventUIRefresh(1)

    -----------------------------------------------------------------------------
    local function No_Undo()end; local function no_undo()reaper.defer(No_Undo)end
    -----------------------------------------------------------------------------
    
    local SelTrack = reaper.GetSelectedTrack( 0, 0 )
    if not SelTrack then no_undo() return end
    
    local CountTrItem = reaper.CountTrackMediaItems( SelTrack )
    if CountTrItem > 0 then
        --local Name = "test"
        for i = 1,CountTrItem do 
            local Tr_item =  reaper.GetTrackMediaItem( SelTrack, i-1 )
            local Take = reaper.GetActiveTake( Tr_item )
            if Take ~= nil then
              local Take_Name = reaper.GetTakeName( Take )
            
              if Take_Name == search then
                  reaper.SelectAllMediaItems( 0, 0 )
                  reaper.SetMediaItemSelected( Tr_item, 1 )
                  undo = 1
                  break
              end
            end       
        end
    end 
    
    if undo == 1 then 
        reaper.Undo_BeginBlock()   
        reaper.Undo_EndBlock( [[Select first item from cursor
                             position in first selected track]],-1)
    else   
        no_undo()
    end                          
    --reaper.UpdateArrange()  
    reaper.PreventUIRefresh(-1)
    reaper.UpdateArrange() -- Update the arrangement (often needed)
  end
end
the input part is from something by xraym (thankyou very much) and the rest is my modified Archie script.

thanks,
babag
babag 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:41 PM.


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