TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CAB on November 15, 2014, 03:11:40 PM
-
Wishing I had the Nudge ability in ACAD2012.
Has anyone seen a reactor that would simulate the Nudge Command?
-
For me NUDGE is highlight object/s then CTRL+SHIFT+ARROW KEY.
AUTOCAD CIVIL 2015 and AUTOCAD MAP 2015 but I assumed this was a Vanilla ACAD shortcut.
or are you talking about something different?
-
Same thing. I am using Chief Architect for a month now & it has that command.
Select an object or objects, hit [arrow] and they move a preset distance.
[Shift] [Arrow] would be 10 times the distance. Distance is in a variable.
Maybe two variables so you can set each separately.
Or three if you can use [Ctrl] [Arrow] too.
I see ACAD2012 has that feature but thought someone would have created a routine for older ACAD versions.
Did not think I would use it when it came out in ACAD but using it lately I kinda like it.
-
I have a rough shortcut routine that I use the numpad arrows to set dimension line offset at standard 3/8" * drawing scale. Uses keyboard accelerators in menu file. I haven't had time to work out right way to due with new CUI. You could modify to check if objects are selected, then issue move command.
//
// menu file
//
***MENUGROUP=XYZ_ACCEL
***ACCELERATORS
["NUMPAD5"]^P(XYZ_keydist "get" nil)
["NUMPAD6"]^P(XYZ_keydist "0" nil)
["NUMPAD9"]^P(XYZ_keydist "45" nil)
["NUMPAD8"]^P(XYZ_keydist "90" nil)
["NUMPAD7"]^P(XYZ_keydist "135" nil)
["NUMPAD4"]^P(XYZ_keydist "180" nil)
["NUMPAD1"]^P(XYZ_keydist "-135" nil)
["NUMPAD2"]^P(XYZ_keydist "-90" nil)
["NUMPAD3"]^P(XYZ_keydist "-45" nil)
[CONTROL+"NUMPAD5"]^P(XYZ_keydist "get" 2.0)
[CONTROL+"NUMPAD6"]^P(XYZ_keydist "0" 2.0)
[CONTROL+"NUMPAD9"]^P(XYZ_keydist "45" 2.0)
[CONTROL+"NUMPAD8"]^P(XYZ_keydist "90" 2.0)
[CONTROL+"NUMPAD7"]^P(XYZ_keydist "135" 2.0)
[CONTROL+"NUMPAD4"]^P(XYZ_keydist "180" 2.0)
[CONTROL+"NUMPAD1"]^P(XYZ_keydist "-135" 2.0)
[CONTROL+"NUMPAD2"]^P(XYZ_keydist "-90" 2.0)
[CONTROL+"NUMPAD3"]^P(XYZ_keydist "-45" 2.0)
;;; lisp code
;;;=========================================================================
;;; XYZ_KEYDIST - Combines input distance with direction for use with numeric keypad accelerators
;;;=========================================================================
(defun XYZ_keydist ( ang mult / return)
(if (and (= 0 (getvar "cmdactive")) (/= "get" ang))
;; pan if no command active
(progn
(command "-pan" (getvar "viewctr") (strcat "@" (rtos (/ (getvar "viewsize") -4.0)) "<" angle))
)
;; return number if active
(progn
(if (not mult)(setq mult 1))
(if (or (not XYZ_KEYDIST_VALUE)
(= ang "get")
) ;or
(setq XYZ_KEYDIST_VALUE
(dos_getreal "Distance"
"Enter distance for keypad entry" ;prompt
7 ;no zero, negative, or null
(* 0.375 (getvar "dimscale"))
) ;cbc_getdist
) ;setq
) ;if
(setq return (strcat "@" (rtos (* mult XYZ_KEYDIST_VALUE)) "<" ang))
)
)
(if return return (princ))
) ;defun
-
Very interesting solution. Thanks for sharing.
I'll have some time tomorrow to test it out. 8)
-
Old one I made a while back: http://sourceforge.net/p/caddons/code/HEAD/tree/General/Editing.LSP
Uses the numpad keys to move in 45 degree directions. Distance moved depends on the zoom factor.
-
Thanks Irné
I'll take a look
-
Well I'm back to this because I had some time today.
Decided to go with the accelerator key method.
;; CAB 05.12.2017
;; Called from Menu Hot Keys
;; [Ctrl]+[Right] (NudgeObjects 0)
;; [Ctrl]+[Left] (NudgeObjects 180)
;; [Ctrl]+[Up] (NudgeObjects 90)
;; [Ctrl]+[Down] (NudgeObjects 2700)
;; [Ctrl]+[5] (NudgeObjects -1) Edit Nudge Distance
(defun NudgeObjects ( ang / ss sel p1 p2 )
(if (not NudgeDist) (setq NudgeDist 1.0)) ; Globle Variable
(setq ss (cadr(ssgetfirst))) ; get anything already selected
(cond
((< ang 0) (setq NudgeDist (getdist "/nEnter new Nudge diatance : ")))
((= 0 (getvar "cmdactive")) ; MOVE if no command active
(if (and (null ss) (not (prompt "\nSelect the objects to move: ")))
(setq ss (ssget "_:L")) )
(setq p1 (vlax-3D-point (trans '(0 0) 1 0))
p2 (vlax-3D-point (trans (polar '(0 0) (/ (* ang pi) 180.0) NudgeDist) 1 0))
)
(vlax-for obj (setq sel (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
(vl-catch-all-apply 'vla-move (list obj p1 p2))
)
(vla-Delete sel)
(sssetfirst nil ss) ; activate the selection set again
)
) ; cond
) ; defun
(vl-load-com)
-
This is similar chx chy chz done 1997
(defun C:CHX ()
(SETVAR "CMDECHO" 0)
(setq sn (getvar "osmode"))
(command "osnap" "near")
(setq x 0)
(princ "\nalters object in X direction")
(setq ht (getstring "\n What is amount of change: "))
(setq newht (strcat ht ",0"))
(while (= x 0)
(setq newobj (entsel "\nPoint to object: "))
(if (/= newobj nil)
(progn
(command "move" newobj "" "0,0" newht)
))
(if (= newobj nil)(setq x 1))
)
)
-
@CAB its impressive that you've done it without (grread)
BTW Thanks to you (or some old code example of yours) I managed to learn (grread), so heres another approach:
(defun C:test
( / f SS grr Stop d k tmp
)
(setq d
50) ; default nudge distance
); and
); lambda
); setq f
(princ "\nPress [W/A/S/D] keys to nudge the SS | [TAB] to set new distance | [ENTER/RMB/LMB] if done: ") )
); cond
); while
); and
); defun C:test
Do you guys ever played Counter-Strike? Try using <W> <A> <S> <D> keys for nudging/moving its quite easy. :)
-
@CAB its impressive that you've done it without (grread)
BTW Thanks to you (or some old code example of yours) I managed to learn (grread), so heres another approach:
(defun C:test
( / f SS grr Stop d k tmp
)
(setq d
50) ; default nudge distance
); and
); lambda
); setq f
(princ "\nPress [W/A/S/D] keys to nudge the SS | [TAB] to set new distance | [ENTER/RMB/LMB] if done: ") )
); cond
); while
); and
); defun C:test
Do you guys ever played Counter-Strike? Try using <W> <A> <S> <D> keys for nudging/moving its quite easy. :)
This code is very useful for me.
Is there any way to add a Regen immediately after each individual nudge? Always after each nudge before exiting?
In any event thank you Grrr1337 for this code.
-
(defun C:test ( / f SS grr Stop d k tmp )
(setq d 50) ; default nudge distance
(setq f
(lambda (SS d k / a p1 p2 i )
(and (setq a (cadr (assoc k '(("W" 90) ("S" 270) ("A" 180) ("D" 0)))))
(setq p1 (vlax-3D-point (trans '(0 0) 1 0))) (setq p2 (vlax-3D-point (trans (polar '(0 0) (/ (* a PI) 180.0) d) 1 0)))
(repeat (setq i (sslength SS)) (vla-Move (vlax-ename->vla-object (ssname SS (setq i (1- i)))) p1 p2) )
); and
); lambda
); setq f
(and (princ "\nSelect objects to nudge: ") (setq SS (ssget "_:L-I")) (sssetfirst nil nil)
(princ "\nPress [W/A/S/D] keys to nudge the SS | [TAB] to set new distance | [ENTER/RMB/LMB] if done: ")
(while (not Stop) (setq grr (grread)) (and (or (equal grr '(2 13)) (member (car grr) '(3 25))) (setq Stop T))
(cond ( (/= (car grr) 2) )
( (setq k (strcase (chr (cadr grr))))
(if (= k "\t") (if (setq tmp (getdist "\nSpecify new distance: ")) (setq d tmp)) (progn (f SS d k) (vl-cmdf "_.REGEN")) )
)
); cond
); while
); and
(princ)
); defun C:test
HTH., M.R.
-
Hi Marko,
That works exactly how I wanted.
Thank you for taking time to help me.
Cheers.
-
Awesome Marko