|
|
|
05-22-2019, 10:34 PM
|
#1
|
Human being with feelings
Join Date: Aug 2016
Posts: 91
|
Reposition Selected Items on All Tracks
I've gotten this script to work for the most part, however I've been having problems getting the positioning of items in relation to others. Essentially I am using a while loop to run through the meat of the actions until the items are positioned correctly. The one problem with this is that (as you can see from the third track) the order changes in certain circumstances. If anyone has a better way to make this work, I'm all ears!
Code:
retval, retvals_csv = reaper.GetUserInputs("Reposition Items on All Tracks", 1, "Distance in Seconds", "1" )
distance = string.match(retvals_csv, "([^,]+)")
while tonumber(distance) < 0 do
reaper.ShowConsoleMsg("Choose a value of 0 or greater. \n")
retval, retvals_csv = reaper.GetUserInputs("Reposition Items on All Tracks", 1, "Distance in Seconds", "1" )
distance = string.match(retvals_csv, "([^,]+)")
end
distance = string.match(retvals_csv, "([^,]+)")
function set_item_pos(i)
item_prev = reaper.GetSelectedMediaItem(0, i)
item_prev_start = reaper.GetMediaItemInfo_Value(item_prev, "D_POSITION")
item_prev_end = (reaper.GetMediaItemInfo_Value(item_prev, "D_LENGTH")) + (item_prev_start)
item_next = reaper.GetSelectedMediaItem(0, i + 1)
item_next_start = reaper.GetMediaItemInfo_Value(item_next, "D_POSITION")
reaper.SetMediaItemInfo_Value(item_next, "D_POSITION", item_prev_end + distance)
end
sel_media_items = reaper.CountSelectedMediaItems(0)
for i = 0, sel_media_items - 1 do
if i + 1 > sel_media_items - 1 then
break
else
set_item_pos(i)
while item_next_start < item_prev_end do
set_item_pos(i)
end
end
end
Last edited by Sonorityscape; 05-22-2019 at 10:43 PM.
|
|
|
05-23-2019, 03:53 AM
|
#2
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,874
|
I already made script for advanced reposotionning :P
https://www.extremraym.com/en/downlo...ce-items-pack/
The Set items pos and order script handle a lot of scenarios like different ways to loop through items (per order selection, time pos or per track) etc... Avoif yourself trouble with complex corner cases and take a look :P
|
|
|
05-23-2019, 09:58 AM
|
#3
|
Human being with feelings
Join Date: Aug 2016
Posts: 91
|
Quote:
Originally Posted by X-Raym
I already made script for advanced reposotionning :P
https://www.extremraym.com/en/downlo...ce-items-pack/
The Set items pos and order script handle a lot of scenarios like different ways to loop through items (per order selection, time pos or per track) etc... Avoif yourself trouble with complex corner cases and take a look :P
|
Thanks. I'm also doing this to develop my scripting abilities. I'm going to take another crack at it and change some things.
|
|
|
05-23-2019, 10:21 AM
|
#4
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,874
|
What you need is to first store items in a table and then used these stored items for your moving loop. Else, it will break cause order of selected items changes a each iteration.
Here is a template I made:
https://github.com/ReaTeam/ReaScript...%20editing.lua
I planned to made a video reascript on this exact subject but I didnt made it so far.
My scripts are open source so you can analyse their code (even premium ones).
|
|
|
05-23-2019, 10:26 AM
|
#5
|
Human being with feelings
Join Date: Aug 2016
Posts: 91
|
Quote:
Originally Posted by X-Raym
What you need is to first store items in a table and then used these stored items for your moving loop. Else, it will break cause order of selected items changes a each iteration.
Here is a template I made:
https://github.com/ReaTeam/ReaScript...%20editing.lua
I planned to made a video reascript on this exact subject but I didnt made it so far.
My scripts are open source so you can analyse their code (even premium ones).
|
Haha, I just started a new script 5 minutes ago with a table to better store the items. Like you said, when the items change position, it was messing everything up. Thank you for the link!
|
|
|
05-23-2019, 11:21 AM
|
#6
|
Human being with feelings
Join Date: Aug 2016
Posts: 91
|
Wow, it works so much easier with the table.
|
|
|
05-23-2019, 11:26 AM
|
#7
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,874
|
table unocks a lot of things. You can store properties, shuffle them, sort them, etc...
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 02:39 AM.
|