Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Replace with an empty item v1.0 #1209

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Items Editing/ilovemedia_Replace with an empty item.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- @description Replace with an empty item
-- @author ilovemedia
-- @version 1.0
-- @about
-- # Replace with an empty item
--
-- Replace the selected item with an empty one with the same name, duration and position.

-- Get the selected item at the current position
local selectedItem = reaper.GetSelectedMediaItem(0, 0)
local take = reaper.GetActiveTake(selectedItem)
local takeName = reaper.GetTakeName(take)
local itemStart = reaper.GetMediaItemInfo_Value(selectedItem, "D_POSITION")
local itemEnd = itemStart + reaper.GetMediaItemInfo_Value(selectedItem, "D_LENGTH")
local itemColor = reaper.GetMediaItemInfo_Value(selectedItem, "I_CUSTOMCOLOR", color)

reaper.GetSet_LoopTimeRange(true, false, itemStart, itemEnd, false) -- Set time selection to match the item to replace

reaper.DeleteTrackMediaItem(reaper.GetMediaItem_Track(selectedItem), selectedItem) -- Delete the original item

reaper.Main_OnCommand(40214,0) -- Insert new item

local emptyItem = reaper.GetSelectedMediaItem(0, 0)
if emptyItem ~= nil then
local emptyTake = reaper.GetActiveTake(emptyItem)
reaper.GetSetMediaItemTakeInfo_String(emptyTake, "P_NAME", takeName, true) -- Rename take to the original name
reaper.SetMediaItemInfo_Value(emptyItem, "I_CUSTOMCOLOR", itemColor) -- Set original color
end

reaper.UpdateArrange()
Loading