Old 01-25-2021, 11:56 AM   #1
jguitarguy27
Human being with feelings
 
Join Date: Oct 2007
Posts: 142
Default simple script help: add empty space before each item

I'm making this simple script that:
1) selects each item successively
2) runs the action "Time selection: Insert empty space at time selection (moving later items)"

This script should in theory insert empty space between each selected item.

Here's what I got, but it's not working:

Code:
function main()
  count_sel_item = reaper.CountSelectedMediaItems (0)
  for i = 0, count_sel_item - 1 do
    reaper.GetSelectedMediaItem(0, i)
    reaper.Main_OnCommand(40200, 1, 0)
  end
end

main()
reaper.UpdateArrange()

Last edited by jguitarguy27; 01-25-2021 at 12:03 PM.
jguitarguy27 is offline   Reply With Quote
Old 01-25-2021, 12:06 PM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

If you want to set an item selected, you should set it selected using this function:

https://mespotin.uber.space/Ultrasch...iaItemSelected
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 01-25-2021, 02:51 PM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

Better work by altering item position property than using native action considering what you want to do.


Also, use this template, it will be more friendmy with position change cause it stores items in a table.




https://github.com/ReaTeam/ReaScript...%20editing.lua
X-Raym is offline   Reply With Quote
Old 01-26-2021, 10:59 AM   #4
jguitarguy27
Human being with feelings
 
Join Date: Oct 2007
Posts: 142
Default

Thank you!
jguitarguy27 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 07:37 PM.


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