home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / misc_lsp.zip / COUNTER.LSP < prev    next >
Text File  |  1987-09-03  |  1KB  |  38 lines

  1. ;COUNTER.LSP
  2. ; This lisp routine is accessed by a menu selection from
  3. ; the Counter.mnu on the sample drawing disk.  It inserts
  4. ; a block called "res" pausing for an insertion point and
  5. ; rotation angle.  If the block is inserted on a line or
  6. ; polyline it will break that entity.
  7.  
  8. ; The routine sets OSNAP to "endpoint" so an error function
  9. ; has been defined to reset OSNAP to "none" if the user 
  10. ; cancels the routine with a ^C.
  11.  
  12. (defun my-error (st)
  13.   (setvar "osmode" 0)
  14.   (princ st) (terpri)
  15.   (setq *error* orig-err)
  16.   (princ)
  17. )
  18. (defun C:res (/ attdia? blk-ang lblock orig-err)
  19.   (setq orig-err *error* *error* my-error)
  20.   (setq attdia? (getvar "attdia"))
  21.   (setvar "osmode" 512) (setvar "attdia" 1)
  22.   (command "insert" "res" pause "1" "1" pause)
  23.   (setq blk-ang (cdr (assoc 50 (entget (entlast)))))
  24.   (entdel (setq lblock (entlast)))
  25.   (setq lp (getvar "lastpoint"))
  26.   (if (ssget lp)
  27.    (progn
  28.     (setq etype (cdr (assoc 0 (entget (ssname (ssget lp) 0)))))
  29.     (if (or (equal etype "LINE") (equal etype "POLYLINE"))
  30.         (command "break" lp (polar lp blk-ang 2))
  31.     )
  32.    )
  33.   )
  34.   (entdel lblock)
  35.   (setvar "osmode" 0) (setvar "attdia" attdia?)
  36.   (setq *error* orig-err) (princ)
  37. )
  38.