Old 07-10-2019, 11:27 AM   #1
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
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: 179
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: 2,227
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: 9,875
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: 2,227
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: 2,227
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: 9,875
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: 2,227
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: Southern Vermont
Posts: 864
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?
__________________

Support my feature request!
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: 9,875
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: 2,227
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: 2,227
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
Old 04-17-2022, 03:26 AM   #13
dahya
Human being with feelings
 
Join Date: Oct 2019
Posts: 229
Default

Quote:
Originally Posted by babag View Post
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?
Bagbag, I'm not a LUA scripter (more of an SQL programmer), but I managed to figure some of this out. I've attached a script that I modified from MPL (thanks MPL) using the script that you posted earlier, and this now only affects the selected track rather than all tracks.



Secondly, I was trying to figure out how to create chords quicker, so the following custom action uses the above script as well as one from Yannick (thanks Yannick) to do this:




The process would be:

1. Create MIDI Item with a chord at the start of song (eg Chord G), make it one bar long.
2. Everywhere else in the song where a G chord is required, create an empty Item with the name G.
3. Run the custom action as above.

Just bear in mind that the MIDI Items you want to paste to need to be the same length as the one you select, else for example if the one you select is 2 bars long, then it will paste ALL pooled items as 2 bars long.

I'm no lua expert, and I think an issue with the above is that if you have midi items with a name of say 'G', with variable length, it will make all the 'G' MIDI Items the same length afterwards...ideally it should only copy/paste items with the same length (source and destination), but I don't have a clue how to do this !
Attached Files
File Type: lua Dahya_Select_Items_Same_Name_as_Input.lua (1.2 KB, 62 views)
dahya is offline   Reply With Quote
Old 04-18-2022, 02:54 AM   #14
dahya
Human being with feelings
 
Join Date: Oct 2019
Posts: 229
Default

Quote:
Originally Posted by dahya View Post
...
Just bear in mind that the MIDI Items you want to paste to need to be the same length as the one you select, else for example if the one you select is 2 bars long, then it will paste ALL pooled items as 2 bars long.

I'm no lua expert, and I think an issue with the above is that if you have midi items with a name of say 'G', with variable length, it will make all the 'G' MIDI Items the same length afterwards...ideally it should only copy/paste items with the same length (source and destination), but I don't have a clue how to do this !
If anyone's interested, I've managed to modify the script (attached) so it checks the Item lengths, and only copies/pastes to items with the same name AND same length.
Attached Files
File Type: lua Dahya_Select_Items_Same_Name_and_Length_as_Input.lua (1.4 KB, 62 views)
dahya is offline   Reply With Quote
Old 08-05-2023, 07:39 AM   #15
ViviZzz
Human being with feelings
 
Join Date: Nov 2022
Posts: 8
Default

Quote:
Originally Posted by dahya View Post
If anyone's interested, I've managed to modify the script (attached) so it checks the Item lengths, and only copies/pastes to items with the same name AND same length.
Thanks!
ViviZzz is offline   Reply With Quote
Old 12-27-2023, 10:16 AM   #16
robotron
Human being with feelings
 
Join Date: May 2020
Posts: 337
Default

Has anyone come across/come up with a version of this that works without needing to input a name each time? I.e. where you can add the take name to the script and then just run it to select all items with this name?
robotron 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 10:57 PM.


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