Old 02-21-2017, 11:15 AM   #1
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 4,771
Default Snap Edit cursor to nearest Grid Line...

Dear Reapers,

Seems that there doesn't exist an Action "Snap Edit Cursor to nearest Grid line".
For my workflow, this Action would be so useful .

Am i overseeing it ?
If not available indeed, is it maybe scriptable ?
Willing to pay generously for it.


Warm Regards.
vanhaze is offline   Reply With Quote
Old 02-21-2017, 11:38 AM   #2
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: City
Posts: 10,359
Default

As long as relative grid is not activated, snapping is on as well as the grid, you just need to nudge your editor cursor to land on the next or previous grid line.

Here's the simple code for LUA, which was actually provided to me by some helpful soul on this forum:
Code:
local val=1
reaper.ApplyNudge(  -- move edit cursor left 1 frame
                   0,    -- ReaProject project
                   2,    -- integer nudgeflag (&1=set to value (otherwise nudge by value), &2=snap)
                   6,    -- 0=position, 1=left trim, 2=left edge, 3=right edge, 4=contents, 5=duplicate, 6=edit cursor
                   18,   -- integer nudgeunits: 0=ms, 1=seconds, 2=grid, 3=256th notes, ..., 15=whole notes, 16=measures.beats (1.15 = 1 measure + 1.5 beats), 17=samples, 18=frames, 19=pixels, 20=item lengths, 21=item selections
                   val,    -- value: amount to nudge by, or value to set to
                   true, -- reverse: in nudge mode, nudges left (otherwise ignored)
                   0     -- copies: in nudge duplicate mode, number of copies (otherwise ignored)
                 )
I use this stuff to move items around, manipulate item edges and so on. You can use the nudge-by-slot actions of course. You'd need to save the right settings in the right slot first. Those load/save actions are only available in the action list though, not in the nudge window itself.
__________________
Dialogue/FX Editor & Re-Recording Mixer
(Video)Using Latch Preview
"My ego comes pre-shrunk" - Randy Thom
airon is offline   Reply With Quote
Old 02-21-2017, 11:48 AM   #3
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 4,771
Default

Quote:
Originally Posted by airon View Post
As long as relative grid is not activated, snapping is on as well as the grid, you just need to nudge your editor cursor to land on the next or previous grid line.
.
Thanks for your help !
But the Action should decide itself if the Edit cursor should be moved backwards or forward, depending on which Gridline is closest to Edit Cursor, the left one or right one.

Workflow:

I have Snap OFF.
I have Grid ON.
I place Edit cursor somewhere between 2 Grid lines.
I execute wishful Script.
Outcome: The Edit Cursor snaps to the nearest Gridline, be it on the left or the right.

Sorry for my misunderstanding if your lua script does exactly this ..:0)
vanhaze is offline   Reply With Quote
Old 02-21-2017, 06:28 PM   #4
ericzang
Human being with feelings
 
ericzang's Avatar
 
Join Date: Mar 2014
Location: Phoenix, AZ
Posts: 351
Default

how about this:
Script: me2beats_Move cursor to nearest grid division.lua
get here:
http://forum.cockos.com/showthread.php?t=186999

seems to do what you ask
ericzang is offline   Reply With Quote
Old 02-21-2017, 11:13 PM   #5
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 4,771
Default

AWESOME !

Thank you !
vanhaze is offline   Reply With Quote
Old 01-22-2018, 08:39 PM   #6
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,639
Default

Is there a way to remove the nudge commands from the undo history?
I tried the trick with the empty function and defer, but the undo points are still shown
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 07-14-2019, 02:42 PM   #7
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,968
Default

I just released a simple script:


  • X-Raym_Snap edit cursor to nearest grid if snap is enabled.lua
Can be useful in custom actions :P
X-Raym 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 05:59 AM.


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