home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 5.img / SUPPORT2.LIB / DDOSNAP.LSP < prev    next >
Encoding:
Text File  |  1992-09-09  |  7.1 KB  |  220 lines

  1. ;;;----------------------------------------------------------------------------
  2. ;;;   DDOSNAP.LSP  ¬⌐Ñ╗ 0.5
  3. ;;;
  4. ;;;   ¬⌐┼v (C) 1991-1992  Autodesk ñ╜Ñq
  5. ;;;
  6. ;;;   Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
  7. ;;;   ¡∞½h :
  8. ;;;
  9. ;;;   1)  ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
  10. ;;;   2)  ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
  11. ;;;
  12. ;;;   Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
  13. ;;;   Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
  14. ;;;
  15. ;;;
  16. ;;;----------------------------------------------------------------------------
  17. ;;;
  18. ;;; ===========================================================================
  19. ;;; ===================== load-time error checking ============================
  20. ;;;
  21.  
  22.   (defun ai_abort (app msg)
  23.      (defun *error* (s)
  24.         (if old_error (setq *error* old_error))
  25.         (princ)
  26.      )
  27.      (if msg
  28.        (alert (strcat " └│Ñ╬╡{ªí┐∙╗~: "
  29.                       app
  30.                       " \n\n  "
  31.                       msg
  32.                       "  \n"
  33.               )
  34.        )
  35.      )
  36.      (exit)
  37.   )
  38.  
  39. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  40. ;;; and then try to load it.
  41. ;;;
  42. ;;; If it can't be found or it can't be loaded, then abort the
  43. ;;; loading of this file immediately, preserving the (autoload)
  44. ;;; stub function.
  45.  
  46.   (cond
  47.      (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.
  48.  
  49.      (  (not (findfile "ai_utils.lsp"))                     ; find it
  50.         (ai_abort "DDOSNAP"
  51.                   (strcat "ºΣñú¿∞íuAI_UTILS.LSPív└╔«╫;"
  52.                           "\n  ╜╨└╦¼díusupportívÑ╪┐²íC")))
  53.  
  54.      (  (eq "failed" (load "ai_utils" "failed"))            ; load it
  55.         (ai_abort "DDOSNAP" "╡L¬k╕ⁿñJíuAI_UTILS.LSPív└╔«╫"))
  56.   )
  57.  
  58.   (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
  59.       (ai_abort "DDOSNAP" nil)         ; a Nil <msg> supresses
  60.   )                                    ; ai_abort's alert box dialog.
  61.  
  62. ;;; ==================== end load-time operations ===========================
  63.  
  64. ;;;----------------------------------------------------------------------------
  65. ;;; The main routine.
  66. ;;;----------------------------------------------------------------------------
  67. (defun c:ddosnap( /
  68.                   ap_size          ddosnap_main    olderr         x2
  69.                   cmd              do_setvars      osmode         x_aperture
  70.                   dcl_id           draw_size       osmode_init    y_aperture
  71.                   ddosnap_err      globals         x1             ap_size_init
  72.                   undo_init
  73.                 )
  74.   ;;
  75.   ;; Pass an integer and draw a square of that size in the aperture image tile.
  76.   ;;
  77.   (defun draw_size (intsize)
  78.     (setq x1 (- (/ x_aperture 2) (1+ intsize) ))
  79.     (setq x2 (+ (/ x_aperture 2) (1+ intsize) ))
  80.     (setq y1 (- (/ y_aperture 2) (1+ intsize) ))
  81.     (setq y2 (+ (/ y_aperture 2) (1+ intsize) ))
  82.     (start_image "aperture_image")
  83.     (fill_image 0 0 x_aperture y_aperture -2)
  84.     (vector_image x1 y1 x2 y1 -1)
  85.     (vector_image x2 y1 x2 y2 -1)
  86.     (vector_image x2 y2 x1 y2 -1)
  87.     (vector_image x1 y2 x1 y1 -1)
  88.     (end_image)
  89.   )
  90.   ;;
  91.   ;;  If OK, set setvars to selected values.
  92.   ;;
  93.   (defun do_setvars()
  94.     (setq osmode 0)
  95.     (if (= "1" (get_tile "endpoint"))
  96.       (setq osmode (logior osmode 1))
  97.     )
  98.     (if (= "1" (get_tile "midpoint"))
  99.       (setq osmode (logior osmode 2))
  100.     )
  101.     (if (= "1" (get_tile "center"))
  102.       (setq osmode (logior osmode 4))
  103.     )
  104.     (if (= "1" (get_tile "node"))
  105.       (setq osmode (logior osmode 8))
  106.     )
  107.     (if (= "1" (get_tile "quadrant"))
  108.       (setq osmode (logior osmode 16))
  109.     )
  110.     (if (= "1" (get_tile "intersection"))
  111.       (setq osmode (logior osmode 32))
  112.     )
  113.     (if (= "1" (get_tile "insertion"))
  114.       (setq osmode (logior osmode 64))
  115.     )
  116.     (if (= "1" (get_tile "perpendicular"))
  117.       (setq osmode (logior osmode 128))
  118.     )
  119.     (if (= "1" (get_tile "tangent"))
  120.       (setq osmode (logior osmode 256))
  121.     )
  122.     (if (= "1" (get_tile "nearest"))
  123.       (setq osmode (logior osmode 512))
  124.     )
  125.     (if (= "1" (get_tile "quick"))
  126.       (setq osmode (logior osmode 1024))
  127.     )
  128.     (if (/= osmode osmode_init)
  129.       (setvar "osmode" osmode)
  130.     )
  131.     (if (/= ap_size ap_size_init)
  132.       (setvar "aperture" (1+ ap_size))
  133.     )
  134.   )
  135.   ;;
  136.   ;; Put up the dialogue.
  137.   ;;
  138.   (defun ddosnap_main()
  139.  
  140.     (if (not (new_dialog "ddosnap" dcl_id)) (exit))
  141.  
  142.     ;; The aperture variable must be within 1 - 20 for display within the image
  143.     ;; tile.  The aperture variable will only be updated if the user moves
  144.     ;; the slider bar (0 - 19).
  145.     (setq ap_size (1- (getvar "aperture")))
  146.     (if (< 19 ap_size) (setq ap_size 19))
  147.     (if (> 0 ap_size) (setq ap_size 0))
  148.     (setq ap_size_init ap_size)
  149.  
  150.     (setq x_aperture (dimx_tile "aperture_image"))
  151.     (setq y_aperture (dimy_tile "aperture_image"))
  152.  
  153.     (set_tile "aperture_slider" (itoa ap_size))
  154.  
  155.     (draw_size ap_size)
  156.  
  157.     (setq osmode_init (getvar "osmode")   ; get initial value of variable
  158.           osmode      osmode_init
  159.     )
  160.     (if (= 1 (logand 1 osmode)) (set_tile "endpoint" "1"))
  161.     (if (= 2 (logand 2 osmode)) (set_tile "midpoint" "1"))
  162.     (if (= 4 (logand 4 osmode)) (set_tile "center" "1"))
  163.     (if (= 8 (logand 8 osmode)) (set_tile "node" "1"))
  164.     (if (= 16 (logand 16 osmode)) (set_tile "quadrant" "1"))
  165.     (if (= 32 (logand 32 osmode)) (set_tile "intersection" "1"))
  166.     (if (= 64 (logand 64 osmode)) (set_tile "insertion" "1"))
  167.     (if (= 128 (logand 128 osmode)) (set_tile "perpendicular" "1"))
  168.     (if (= 256 (logand 256 osmode)) (set_tile "tangent" "1"))
  169.     (if (= 512 (logand 512 osmode)) (set_tile "nearest" "1"))
  170.     (if (= 1024 (logand 1024 osmode)) (set_tile "quick" "1"))
  171.  
  172.     (action_tile "aperture_slider"
  173.                  "(draw_size (setq ap_size (atoi $value)))")
  174.     (action_tile "help" "(acad_helpdlg \"acad.hlp\" \"ddosnap\")")
  175.     (action_tile "accept" "(do_setvars)(done_dialog)")
  176.  
  177.     (start_dialog)
  178.   )
  179.  
  180.   ;; Set up error function.
  181.   (setq old_cmd (getvar "cmdecho")    ; save current setting of cmdecho
  182.         old_error  *error*            ; save current error function
  183.         *error* ai_error              ; new error function
  184.   )
  185.  
  186.   (setvar "cmdecho" 0)
  187.  
  188.   (cond
  189.      (  (not (ai_transd)))                       ; transparent OK
  190.      (  (not (ai_acadapp)))                      ; ACADAPP.EXP xloaded?
  191.      (  (not (setq dcl_id (ai_dcl "ddosnap"))))  ; is .DCL file loaded?
  192.  
  193.      (t (if (and (/= 1 (logand 1 (getvar "cmdactive")))
  194.                  (/= 8 (logand 8 (getvar "cmdactive")))
  195.             )
  196.          (ai_undo_push)
  197.         )
  198.  
  199.         (ddosnap_main)                          ; proceed!
  200.  
  201.         (if (and (/= 1 (logand 1 (getvar "cmdactive")))
  202.                  (/= 8 (logand 8 (getvar "cmdactive")))
  203.             )
  204.          (ai_undo_pop)
  205.         )
  206.  
  207.      )
  208.   )
  209.  
  210.  
  211.   (setq *error* old_error)
  212.   (setvar "cmdecho" old_cmd)
  213.   (princ)
  214. )
  215. ;;;----------------------------------------------------------------------------
  216. (princ "  íuDDOSNAPívñw╕ⁿñJíC")
  217. (princ)
  218.  
  219.  
  220.