Ever had this happen ??
Command:
Select Start Point (ENTER to QUIT) :
Select End Point: 's
Can't reenter LISP.
Invalid point.
Select End Point:
Quite often you may need to set the SNAPANG in the middle of a lisp routine. .. well I often do anyway.
Using a transparent command such as 'Snapang in the middle of a routine when prompted for points works fine
.. except it a pain typing the command
SO, defining SA as an alias for SNAPANG in your pgp solves that.
Except : SNAPANG only accepts selected points ( a pain to select OSNAPS for sometimes ) or a typed angle value (which you may not remember, or get jumbled if you're a little dyslectic )
So a solution that works for me is to define a function ( not a c: command) to select an object and have the routine change SNAPANG to suit the object.
Then, use (vlax-add-cmd with the ACRX_CMD_TRANSPARENT flag to register the command.
Here's the code :
;;;----------------------------------------------------------------------------
;;;----------------------------------------------------------------------------
;;;* Snap to entity.
;;; codehimbelonga kdub
;;;* (KDUB:SnapTo)
(defun kdub:snapto (/ ent elist i li e1 e2 ang tmp)
(if (setq ent
(entsel
(strcat
"\nSNAP TO line,pline,text,insert ... select object OR ENTER for <"
(angtos (getvar "SNAPANG") 0 4)
">:"
)
)
)
(progn (setq ename (car ent) ; (type (car ent))
elist (entget ename)
)
(cond ((= (cdr (assoc 0 elist)) "POLYLINE")
(setq e1 (entget (entnext ename))
e2 (entget (entnext (cdr (assoc -1 e1))))
)
(setq ang (angle (trans (cdr (assoc 10 e1)) 0 1)
(trans (cdr (assoc 10 e2)) 0 1)
)
)
)
((= (cdr (assoc 0 elist)) "LWPOLYLINE")
(setq i (fix (vlax-curve-getparamatpoint
ename
(vlax-curve-getclosestpointto ename (osnap (cadr ent) "nea"))
)
)
ang (angle (trans (vlax-curve-getpointatparam ename i) 0 1)
(trans (vlax-curve-getpointatparam ename (1+ i)) 0 1)
)
)
)
((= (cdr (assoc 0 elist)) "LINE")
(setq ang (angle (trans (cdr (assoc 10 elist)) 0 1)
(trans (cdr (assoc 11 elist)) 0 1)
)
)
)
((member (cdr (assoc 0 elist)) '("TEXT" "MTEXT" "INSERT"))
(setq ang (cdr (assoc 50 elist)))
)
)
(if ang
;;(setvar "SNAPANG" (kdub:rtd ang))
(setvar "SNAPANG" ang)
)
)
)
(prompt (strcat "\n Snap Angle set to "
(angtos (getvar "SNAPANG") 0 4)
" Degrees\n"
)
)
;;(PRINC)
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
(vlax-add-cmd "saa" 'kdub:snapto "saa" ACRX_CMD_TRANSPARENT )
NOTE : change the
'global-name' "SAA" to whatever suits you.
jsyn, I used saa because the letters are close together on the keyboard, didn't conflict with any other command name
and is sort of an acronym for
Snap
Angle to
Aligned ... works for me
Then, in the middle of a lisp routine you can enter 'SAA to transparently select an entity and have the SNAPANG value change to suit.
The command can also be used normally at the command line.
No more stopping commands in the middle ....