View Single Post
Old 04-29-2018, 11:09 PM   #1650
cool
Human being with feelings
 
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 160
Default

Ha! It's hard to believe, but I think I completely solved my problem! At least the first tests were excellent!

I combined several solutions - a successful "remove" action and additional commands to solve their requests. Perhaps this does not look correct from the programmer's point of view, but .... it works!
The script has one drawback. With any selection of the area, the automation items are not deleted. But this is a trifle, in my workflow I can ignore it without much trouble.

FnA, James HE, guys, thank you very much for your help! This is priceless for me!

Final code:

Code:
start, ending = reaper.GetSet_LoopTimeRange( 0, 0, 0, 0, 0 )
--focus = reaper.GetCursorContext()
focus = reaper.GetCursorContext2(true) -- unlikely to get unknown(-1) when arrange not focused


  script_title = "Smart Delete Script" 
  reaper.Undo_BeginBlock() 

if start == ending then
  reaper.Main_OnCommand(40697, 0) -- remove items/tracks/...
else
  if focus == 1 then
    reaper.Main_OnCommand(40061, 0) -- split items at time selection
    reaper.Main_OnCommand(40697, 0) -- remove selected area of items
  elseif focus == 2 then
    reaper.Main_OnCommand(40333, 0)  --  delete selected points
  else -- alternatively -- elseif focus == 0 then
    reaper.Main_OnCommand(40697, 0) -- remove tracks
  end
end

  reaper.Undo_EndBlock(script_title, 0)

Last edited by cool; 04-30-2018 at 01:40 AM.
cool is offline   Reply With Quote