Actually, I tried both, but I can't get a choice - either a pre-existing selection set or if none, prompt for one. Not
sure what I'm missing.
HOWEVER - more importantly, in testing this, even though I can get the correct angle direction, the moving of the
objects selected seems to be somewhat arbitrary and unpredictable. I can't think what I have programmed incorrectly, but
sometimes it doesn't move the objects at all, and other times it moves them a peculiar distance - is it my cond
statements, or the way I have set up the move points?
Latest version:-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Nudge - gets selection set, sets polar angle to 45 ;;;
;;; & offers preset nudge distance to accept or change ;;;
;;; Gordon Stephens 28-10-2007 ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[code]
(defun c:nudge-g ( / ortho pang asnp pntdir1 sset elist angdir) ; angdir-d)
(setvar "cmdecho" 0)
(setq sset nil)
(getnudge)
(setq ortho (getvar "orthomode"))
(if (= ortho 1) (setvar "orthomode" 0)) ; if
(setq pang (getvar "polarang"))
(if (/= pang 45.0) (setvar "polarang" (/ pi 4))) ; if
(setq asnp (getvar "autosnap"))
(if (/= asnap 47) (setvar "autosnap" 47)) ; if
(prompt "\nobjects to nudge")
(setq sset (ssget))
(setq pntdir1 (getpoint "\npick any reference/start point"))
(prompt "\npick point in direction of nudge")
(command "line" pntdir1 pause "")
(setq elist (entget (entlast))) (command "erase" "Last" "")
(setq angdir (angle (cdr (assoc 10 elist)) (cdr (assoc 11 elist))))
(setq angdir-d (rtd angdir))
(cond
((= angdir-d 0.0) (command "move" sset "" "d" (list ndg1 0.0)))
((= angdir-d 45.0) (command "move" sset "" "d" (list ndg1 ndg1)))
((= angdir-d 90.0) (command "move" sset "" "d" (list 0.0 ndg1)))
((= angdir-d 135.0) (command "move" sset "" "d" (list (- ndg1) ndg1)))
((= angdir-d 180.0) (command "move" sset "" "d" (list (- ndg1) 0.0)))
((= angdir-d 225.0) (command "move" sset "" "d" (list (- ndg1) (- ndg1))))
((= angdir-d 270.0) (command "move" sset "" "d" (list 0.0 (- ndg1))))
((= angdir-d 315.0) (command "move" sset "" "d" (list ndg1 (- ndg1))))
) ; cond
(setvar "orthomode" ortho)
(setvar "polarang" pang)
(setvar "autosnap" asnp)
(princ)
) ; defun
(defun rtd (r) (* (/ 180.0 pi) r))
(defun dtr (r) (* (/ n 180.0) pi))
(defun getnudge ()
(if (= ndg1 nil)
(progn
(setq ndg1 20.0)
)
)
(initget 2)
(setq message (strcat "\nCurrent distance to nudge objects horz/vert <" (rtos ndg1 2) ">:"))
(setq ndg (getreal message))
(if (/= ndg nil)
(progn
(setq ndg1 ndg)
)
)
)
[/code]
--
Gordon.
"Rod" wrote in message news:5762833@discussion.autodesk.com...
Your (command "polarang") is emptying your current selection set either set
this using (setvar "polarang" (/ pi 2)) and ssget will grab what is
highlighted
OR
or use (ssget "i") before this to get the contents of the current selection
set
this returns nil if nothing is selected or returns the selection set if
there is something selected.
"