Nudge

Discussion in 'AutoCAD' started by Kevin Lockwood, May 27, 2004.

  1. I searched and didn't find anything, so I thought I'd ask...

    Has anyone come up with a "Nudge" macro (or whatever) to move objects
    using the arrow keys? This feature is common in many graphic programs
    and I've tried a few times but just havent figured itr out yet.

    Anyone, anyone?
     
    Kevin Lockwood, May 27, 2004
    #1
  2. Kevin Lockwood

    OLD-CADaver Guest

    GRIPS
     
    OLD-CADaver, May 27, 2004
    #2
  3. Kevin Lockwood

    Allen Jessup Guest

    Start the move command. Select the object you want to move. Hold down the
    CTRL key. Hit an arrow key once of twice. Let up on the CTRL key. Hit the
    Space Bar. Hold down the CTRL key. Use the arrow keys to move the object.
    Hit space bar to finish. You used to able to use Pg Up & Pg Dn to change the
    amount of movement but I haven't figured out how to do that now.

    Allen
     
    Allen Jessup, May 27, 2004
    #3
  4. Kevin Lockwood

    TCEBob Guest

    Hey, Kev, Please don't double-post!

    If you command MOVE and pick the start point you can hang on to the control key
    and use the arrows. Hit space to end. Alas, the old convention of using
    home,pageup,end and pagedown seems to have been lost.

    rs
     
    TCEBob, May 27, 2004
    #4
  5. Concider wrist slapped.

    That worked fine, thanks. Too bad you cant just go to the arrows.
     
    Kevin Lockwood, May 27, 2004
    #5
  6. Kevin Lockwood

    andywatson Guest

    This will nudge using the arrows on the number keypad (numlock = on). The command is "nudge", of course you can map it to a toolbar button or whatever.
    You can highlight the items you'd like to nudge before you begin the command, avoiding the "select objects" prompt altogether.
    After starting the command, type "S" to change nudge increment, or <Enter> to exit.
    Hope it helps.
    Andrew

    ;; Nudge routine written by Andrew Watson 2004
    ;;


    ;; moveEntities function
    ;; input: ss - selection set, ang - direction to move in radians
    ;; output: none
    (defun moveEntities (ss ang / )
    ;; pt = point to move from
    ;; newpt = point to move to
    (setq pt (list 0 0 0)
    newpt (polar pt ang *nudgeIncrement*)
    )
    ;; turn off command text to command line
    (setq cmdecho (getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    ;; move selection set from point to point
    (command "move" ss "" pt newpt)
    ;; reset command text
    (setvar "CMDECHO" cmdecho)
    ); defun


    ;; nudge main program
    ;; will move highlighted or selected items by user-specified
    ;; distance in an up, down, left or right direction
    (defun c:nudge ( / ss key continueNudge)
    ;; initialize variables
    (if (null *nudgeIncrement*)
    (setq *nudgeIncrement* 0.1)
    )
    (setq continueNudge T)

    ;; get highlighted entities
    (setq ss (cadr (ssgetfirst)))
    ;; if no entities highlighted, prompt for selection set
    (while (null ss)
    (progn
    (prompt "\nSelect entities to \"nudge\"...")
    (setq ss (ssget))
    ); progn
    ); while

    (prompt "\nUse the arrows on the number keypad, S for settings, <Enter> to exit...")

    ;; loop until user presses <enter>
    (while continueNudge
    ;; loop until grread returns a key press
    (while (/= (car (setq key (grread))) 2))
    ;; get value of key
    (setq key (cadr key))
    (cond
    ;; 2 = down
    ((= key 50)
    (moveEntities ss (* (/ PI 2) 3))
    )
    ;; 4 = left
    ((= key 52)
    (moveEntities ss PI)
    )
    ;; 6 = right
    ((= key 54)
    (moveEntities ss 0)
    )
    ;; 8 = up
    ((= key 56)
    (moveEntities ss (/ PI 2))
    )
    ;; s or S = settings
    ((or (= key 83)
    (= key 115))
    (setq tmp (getreal (strcat "\nNew nudge increment value <" (rtos *nudgeIncrement* 2 2) "> : ")))
    (if tmp (setq *nudgeIncrement* tmp))
    (prompt "\nUse the arrows on the number keypad, S for settings, <Enter> to exit...")
    )
    ;; <enter> = exit
    ((= key 13)
    (setq continueNudge nil)
    )
    (T nil)
    ); cond
    ); while
    (princ)
    ); defun
     
    andywatson, May 27, 2004
    #6
  7. Kevin Lockwood

    Allen Jessup Guest

    Lost that when they started letting you page through the previous command
    lines with the arrow keys.
     
    Allen Jessup, May 27, 2004
    #7
  8. Kevin Lockwood

    TCEBob Guest

    Pretty nice, Andy. I haven't run it yet but I will. How 'bout using the 1 3 7 9
    keys for 45 degrees?

    rs
     
    TCEBob, May 27, 2004
    #8
  9. Kevin Lockwood

    andywatson Guest

    Oh, alright.
    There was an error anyway, when you ran the routine with items already selected...it's fixed.

    ;; Nudge routine written by Andrew Watson 2004
    ;;


    ;; moveEntities function
    ;; input: ss - selection set, ang - direction to move in radians
    ;; output: none
    (defun moveEntities (ss ang / )
    ;; pt = point to move from
    ;; newpt = point to move to
    (setq pt (list 0 0 0)
    newpt (polar pt ang *nudgeIncrement*)
    )
    ;; turn off command text to command line
    (setq cmdecho (getvar "CMDECHO"))
    (setvar "CMDECHO" 0)
    ;; move selection set from point to point
    (command "move" ss "" pt newpt)
    ;; reset command text
    (setvar "CMDECHO" cmdecho)
    ); defun


    ;; nudge main program
    ;; will move highlighted or selected items by user-specified
    ;; distance in an up, down, left or right direction
    (defun c:nudge ( / ss key continueNudge)
    ;; initialize variables
    (if (null *nudgeIncrement*)
    (setq *nudgeIncrement* 0.1)
    )
    (setq continueNudge T)

    ;; get gripped entities
    (if (setq ss (cadr (ssgetfirst)))
    ;; ungrip
    (sssetfirst nil nil)
    ); if
    ;; if no entities highlighted, prompt for selection set
    (while (null ss)
    (progn
    (prompt "\nSelect entities to \"nudge\"...")
    (setq ss (ssget))
    ); progn
    ); while

    (prompt "\nUse the arrows on the number keypad, S for settings, <Enter> to exit...")

    ;; loop until user presses <enter>
    (while continueNudge
    ;; loop until grread returns a key press
    (while (/= (car (setq key (grread))) 2))
    ;; get value of key
    (setq key (cadr key))
    (cond
    ;; 1 = down-left
    ((= key 49)
    (moveEntities ss (* (/ PI 2) 3))
    (moveEntities ss PI)
    )
    ;; 2 = down
    ((= key 50)
    (moveEntities ss (* (/ PI 2) 3))
    )
    ;; 3 = down-right
    ((= key 51)
    (moveEntities ss (* (/ PI 2) 3))
    (moveEntities ss 0)
    )
    ;; 4 = left
    ((= key 52)
    (moveEntities ss PI)
    )
    ;; 6 = right
    ((= key 54)
    (moveEntities ss 0)
    )
    ;; 7 = up-left
    ((= key 55)
    (moveEntities ss (/ PI 2))
    (moveEntities ss PI)
    )
    ;; 8 = up
    ((= key 56)
    (moveEntities ss (/ PI 2))
    )
    ;; 9 = up-right
    ((= key 57)
    (moveEntities ss (/ PI 2))
    (moveEntities ss 0)
    )
    ;; s or S = settings
    ((or (= key 83)
    (= key 115))
    (setq tmp (getreal (strcat "\nNew nudge increment value <" (rtos *nudgeIncrement* 2 2) "> : ")))
    (if tmp (setq *nudgeIncrement* tmp))
    (prompt "\nUse the arrows on the number keypad, S for settings, <Enter> to exit...")
    )
    ;; <enter> = exit
    ((= key 13)
    (setq continueNudge nil)
    )
    (T nil)
    ); cond
    ); while
    (princ)
    ); defun
     
    andywatson, May 28, 2004
    #9
  10. Kevin Lockwood

    Grizzly Guest

    nudge, nudge, wink, wink, say no more...
     
    Grizzly, May 28, 2004
    #10
  11. Kevin Lockwood

    cadcoke4 Guest

    Thanks, 90% of my work is with 1x1 to 2x4 steel framing. So those simle nudges are very useful..

    I added it to my start-up suite.
     
    cadcoke4, Jun 2, 2004
    #11
  12. Kevin Lockwood

    andywatson Guest

    great!
     
    andywatson, Jun 2, 2004
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
Loading...