Scott Haugh wrote:
> I used to use a mac & a program called "powercad". It had a command called
> "nudge" which allowed you to preselect objects, then hit the 4 arrow keys to
> move the selection set on the orthogonal axes.
>
> the nudge amount is a preset (but variable) amount - and it's an incredibly
> useful tool.
Here's my version...
You'll have to add your own error-control, though.
I haven't been through to ensure that it works on lwpolylines either...
You'll hafta do further modifications if you want to use accelerator keys with
it...
;;* Nudge.lsp -- by Phill Ash (
[email protected])
;;* 13 July 99 --modified 29 Jan 00
;;* Nudge Entities.
;;* User inputs Nudge distance and routine does the following:
;;* If entity or picked segment of entity is straight,
;;* entity is MOVEd the input distance in a direction vector
perpendicular
;;* to the entity or segment of the entity.
;;* If entity or picked segment of entity is curved,
;;* entity is OFFSET the input distance in a direction vector
;;* inside or outside the old entity - which is, then, ERASEd.
;;* MODIFIED FOR STAND-ALONE USE
;;**************************************************************
(defun ASH_dxf (code)
(cdr (assoc code ent))
)
;;**************************************************************
(defun ASH_online (tpt ep1 ep2 / m yint)
(cond
((equal (car ep2) (car ep1) 0.0001) ; line is vertical
(if (equal (car ep2) (car tpt) 0.0001) ; and tpt is on it
(if
(or (and (<= (cadr ep1) (cadr tpt)) (<= (cadr tpt) (cadr ep2)))
(and (<= (cadr ep2) (cadr tpt)) (<= (cadr tpt) (cadr ep1)))
)
t
)
)
)
((equal (cadr ep2) (cadr ep1) 0.0001)
(if (equal (cadr tpt) (cadr ep2) 0.0001)
t
)
)
(t
(setq m (/ (- (cadr ep2) (cadr ep1)) (- (car ep2) (car ep1)))
yint (- (cadr ep2) (* m (car ep2)))
)
(if (equal (cadr tpt) (+ yint (* m (car tpt))) 0.0001)
t
)
)
)
)
;;**************************************************************
(defun nudgeme ( / dir rot v2 vl)
(initget (+ 2 4))
(while (/= (setq name (entsel "\nPick Entity to Nudge: ")) nil)
(setq ent (entget (car name)) ppt (osnap (cadr name) "nea"))
(if (= (ASH_dxf 0) "POLYLINE")
(progn
(while (not rot)
(setq en1 (entnext (ASH_dxf -1)) ent (entget en1))
(if (not (setq v1 (ASH_dxf 10)))
(setq v1 vl)
)
(if v2
(if (/= v2 v1)
(if (ASH_online ppt v1 v2)
(setq rot (angle v1 v2))
(setq v2 v1)
)
)
(setq v2 v1 vl v1)
)
)
)
)
(setq pt1 (getpoint ppt "\nSelect Direction Vector for Nudge"))
(command "_.LINE" pt1 (osnap ppt "per") "" "_.ERASE" "L" "")
(if
(or
(or
(= (ASH_dxf 0) "CIRCLE")
(= (ASH_dxf 0) "SPLINE")
)
(or
(= (ASH_dxf 0) "ARC")
(= (ASH_dxf 0) "ELLIPSE")
)
)
(progn
(setvar "OFFSETDIST" ASH_nud_fac)
(command "_.OFFSET" "" name pt1 "" "_.ERASE" name "")
)
(progn
(setq dir (angle (getvar "LASTPOINT") pt1))
(command "_.MOVE" name "" ppt (polar ppt dir ASH_nud_fac))
)
)
)
(princ)
)
;;** Main Program
(defun c:n ( / o_er svarl fac)
(command "_.UNDO" "GROUP")
(setq or_osmode (getvar "OSMODE"))
(setvar "OSMODE" 0)
(setq lu (getvar "LUNITS"))
(if (null ASH_nud_fac)
(setq cue (strcat "\nNudge Factor: "))
(setq cue (strcat "\nNudge Factor <" (rtos ASH_nud_fac lu) ">: "))
)
(if (setq fac (getreal cue))
(setq ASH_nud_fac fac)
)
(if (and (/= ASH_nud_fac 0.0)(numberp ASH_nud_fac))
(nudgeme)
(princ "\n ZERO??!! Come back when you get a real Nudge Factor!")
)
(setvar "OSMODE" or_osmode)
(command "_.UNDO" "END")
)