home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 v2.4 Fix / W95-v2.4fix.iso / ACADWIN / SUPPORT / DDVIEW.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1995-02-08  |  25.0 KB  |  757 lines

  1. ; Next available MSG number is    26 
  2. ; MODULE_ID DDVIEW_LSP_
  3. ;;;
  4. ;;;    ddview.lsp
  5. ;;;
  6. ;;;    Copyright (C) 1992, 1994 by Autodesk, Inc.
  7. ;;;
  8. ;;;    Permission to use, copy, modify, and distribute this software
  9. ;;;    for any purpose and without fee is hereby granted, provided
  10. ;;;    that the above copyright notice appears in all copies and
  11. ;;;    that both that copyright notice and the limited warranty and
  12. ;;;    restricted rights notice below appear in all supporting
  13. ;;;    documentation.
  14. ;;;
  15. ;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  16. ;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  17. ;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  18. ;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  19. ;;;    UNINTERRUPTED OR ERROR FREE.
  20. ;;;
  21. ;;;    Use, duplication, or disclosure by the U.S. Government is subject to
  22. ;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer
  23. ;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) 
  24. ;;;    (Rights in Technical Data and Computer Software), as applicable.
  25. ;;;
  26. ;;;.
  27. ;;;    DESCRIPTION
  28. ;;;
  29. ;;;    Dialogue interface to VIEW command.  Uses DDVIEW.DCL
  30. ;;;
  31. ;;;----------------------------------------------------------------------------
  32. ;;;    Prefixes in command and keyword strings: 
  33. ;;;      "."  specifies the built-in AutoCAD command in case it has been        
  34. ;;;           redefined.
  35. ;;;      "_"  denotes an AutoCAD command or keyword in the native language
  36. ;;;           version, English.
  37. ;;;----------------------------------------------------------------------------
  38. ;;;
  39. ;;; ===================== load-time error checking ============================
  40. ;;;
  41.  
  42.   (defun ai_abort (app msg)
  43.      (defun *error* (s)
  44.         (if old_error (setq *error* old_error))
  45.         (princ)
  46.      )
  47.      (if msg
  48.        (alert (strcat " Error en la aplicaci≤n: "
  49.                       app
  50.                       " \n\n  "
  51.                       msg
  52.                       "  \n"
  53.               )
  54.        )
  55.      )
  56.      (exit)
  57.   )
  58.  
  59. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  60. ;;; and then try to load it.
  61. ;;;
  62. ;;; If it can't be found or it can't be loaded, then abort the
  63. ;;; loading of this file immediately, preserving the (autoload)
  64. ;;; stub function.
  65.  
  66.   (cond
  67.      (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.
  68.  
  69.      (  (not (findfile ;|MSG0|;"ai_utils.lsp"))                     ; find it
  70.         (ai_abort "DDVIEW"
  71.                   (strcat "Imposible localizar el  archivo AI_UTILS.LSP."
  72.                           "\n Compruebe el directorio de soporte.")))
  73.  
  74.      (  (eq ;|MSG0|;"failed" (load "ai_utils" ;|MSG0|;"failed"))            ; load it
  75.         (ai_abort "DDVIEW" "Imposible cargar el archivo AI_UTILS.LSP"))
  76.   )
  77.  
  78.   (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
  79.       (ai_abort "DDVIEW" nil)         ; a Nil <msg> supresses
  80.   )                                    ; ai_abort's alert box dialog.
  81.  
  82. ;;; ==================== end load-time operations ===========================
  83.  
  84. ;;;
  85. ;;; DDVIEW code.
  86. ;;;
  87. (defun c:ddview ( /  
  88.                 ai_abort        lboxlist          restore_view       vt           
  89.                 appname         lboxname          rm_item            vtar         
  90.                 check_name      list_no           s                  what_next    
  91.                 dcl_id          make-lists        save_view          what_next1   
  92.                 delete          name              temp_lisp_list     what_space   
  93.                 delete_list     named_others      the_list           which_save   
  94.                 describe        new_names         update_list        wid          
  95.                 enable_rad      new_others        value              wview        
  96.                 errmsg          new_view          vcen               x1y1         
  97.                                 new_view_name     vdir               x2           
  98.                 grey_des        no_redefine       viewname           x2y2         
  99.                 hi              old_cmd           viewtype           y1           
  100.                 init_list       old_error                            y2           
  101.                 j               picked_no         vmode              undo_init
  102.                 lab             restorable                  
  103.                                 restore           vnlist          
  104.          )
  105.   ;;
  106.   ;; Pass an item and a list and recieve a number showing it's position in  
  107.   ;; the list, nil otherwise.  Item must be in the list, and the list must 
  108.   ;; contain unique names. 0 if first item.                               
  109.   ;;
  110.   (defun what_pos (item the_list / pos)
  111.     (setq pos (- (length the_list)
  112.                  (length (member item the_list)))
  113.     )          
  114.   )
  115.   ;;
  116.   ;; Get information for description of new (not existing yet) views.
  117.   ;;
  118.   (defun new_others()
  119.     (if (cdr (assoc viewname new_names))
  120.       (progn 
  121.         (setq wid (abs (- x2 x1)))
  122.         (setq hi (abs (- y2 y1))) 
  123.       )
  124.       (progn
  125.         (setq wid (/ (* (getvar "viewsize") (abs (- x2 x1)))
  126.                      (abs (- y2 y1))
  127.                   )
  128.         )
  129.         (setq hi (getvar "viewsize"))
  130.       )
  131.     ) 
  132.     (set_tile ;|MSG0|;"v_height" (rtos hi))
  133.     (set_tile ;|MSG0|;"v_width" (rtos wid))
  134.     (set_tile ;|MSG0|;"v_twist" (angtos (getvar "viewtwist")))
  135.     (set_tile ;|MSG0|;"lens" (rtos (getvar "lenslength")))
  136.     (set_tile ;|MSG0|;"fclip" (rtos (getvar "frontz")))
  137.     (set_tile ;|MSG0|;"bclip" (rtos (getvar "backz")))
  138.  
  139.     ;; Viewdir is stored in UCS (yeah UCS)
  140.     (setq vdir (getvar "viewdir"))
  141.     (if (= 1 wview)
  142.       (setq vdir (trans vdir 1 0 T))
  143.     )
  144.     (set_tile ;|MSG0|;"vdir_x" (rtos (car vdir)))
  145.     (set_tile ;|MSG0|;"vdir_y" (rtos (cadr vdir)))
  146.     (set_tile ;|MSG0|;"vdir_z" (rtos (caddr vdir)))
  147.  
  148.     (setq vmode (getvar "viewmode"))
  149.     (if (= (logand 2 vmode) 2) 
  150.       (set_tile "fclipon" "ACT")
  151.       (set_tile "fclipon" "DES")
  152.     )
  153.     (if (= (logand 4 vmode) 4) 
  154.       (set_tile "bclipon" "ACT")
  155.       (set_tile "bclipon" "DES")
  156.     )
  157.     (if (= (logand 1 vmode) 1) 
  158.       (progn 
  159.         (set_tile "persp" "ACT")
  160.         (if (= 1 wview)
  161.           (setq lab "Motivo (SCU)")
  162.           (setq lab "Motivo (SCP)")
  163.         )
  164.         (set_tile ;|MSG0|;"cen_tar" lab)
  165.         (setq vtar (getvar "target"))
  166.         ;; Target is stored in UCS
  167.         (if (= 1 wview)               
  168.           (setq vtar (trans vtar 1 0))
  169.         )
  170.         (set_tile ;|MSG0|;"vtar_x" (rtos (car vtar)))
  171.         (set_tile ;|MSG0|;"vtar_y" (rtos (cadr vtar)))
  172.         (set_tile ;|MSG0|;"vtar_z" (rtos (caddr vtar)))
  173.       )  
  174.       (progn
  175.         (set_tile "persp" "DES")
  176.         (if (= 1 wview)
  177.           (setq lab "Centro (SCU)")
  178.           (setq lab "Centro (SCP)")
  179.         )
  180.         (set_tile ;|MSG0|;"cen_tar" lab)
  181.         ;; Viewctr is stored UCS
  182.         (setq vtar (getvar "viewctr"))
  183.         (if (= 1 wview)
  184.           (setq vtar (trans vtar 1 0))
  185.         )
  186.         (set_tile ;|MSG0|;"vtar_x" (rtos (car vtar)))
  187.         (set_tile ;|MSG0|;"vtar_y" (rtos (cadr vtar)))
  188.         (set_tile ;|MSG0|;"vtar_z" (rtos (caddr vtar)))
  189.       )
  190.     )
  191.   )
  192.  
  193.   ;;
  194.   ;; Description of view.
  195.   ;;
  196.   (defun describe ()
  197.     ;;
  198.     ;; Views can either be new or existing.  New views that are created 
  199.     ;; are based on the current display and current settings of a bunch
  200.     ;; of system variables.  Existing views have their description stored
  201.     ;; in the View symbol table referenced by a number of group codes.
  202.     ;; If perspective is on, a Target point is described and if perspective 
  203.     ;; is off a Center point is described.  If Worldview is on (1), the 
  204.     ;; direction and Center/Target points are described in WCS rather than
  205.     ;; UCS.
  206.     ;;
  207.     ;;                     Center           Target          Direction
  208.     ;; New Views
  209.     ;; Perspective ON        -            target (UCS)      viewdir (UCS)
  210.     ;; Perspective OFF    viewctr (UCS)       -             viewdir (UCS)
  211.     ;;
  212.     ;; Named Views
  213.     ;; Perspective ON        -             12 Group (WCS)    11 Group (UCS)
  214.     ;; Perspective OFF    10 group (DCS)      -              11 Group (UCS)
  215.     ;;
  216.     ;;
  217.  
  218.     (setq wview (getvar "worldview"))
  219.     (setq viewname (nth (atoi picked_no) vnlist))
  220.         (if (not (new_dialog ;|MSG0|;"vinquiry" dcl_id)) (exit))
  221.  
  222.         (set_tile ;|MSG0|;"v_name" viewname)
  223.  
  224.         (if (= 1 wview)
  225.           (setq lab "Direcci≤n (SCU)")
  226.           (setq lab "Direcci≤n (SCP)")
  227.         )
  228.         (set_tile ;|MSG0|;"direction" lab)
  229.  
  230.         (if (or (assoc viewname new_names)
  231.                 (= "*ACTUAL*" viewname)
  232.             )
  233.           (new_others)
  234.           (named_others)
  235.         )
  236.  
  237.         (action_tile ;|MSG0|;"accept" "(done_dialog 1)")
  238.         (start_dialog)
  239.   )
  240.   ;;
  241.   ;; Get information for description of existing views.
  242.   ;; 
  243.   (defun named_others()
  244.     (setq vt (tblsearch ;|MSG0|;"view" viewname))
  245.     (set_tile ;|MSG0|;"v_height" (rtos (cdr (assoc 40 vt))))
  246.     (set_tile ;|MSG0|;"v_width" (rtos (cdr (assoc 41 vt))))
  247.     (set_tile ;|MSG0|;"v_twist" (angtos (cdr (assoc 50 vt))))
  248.     (set_tile ;|MSG0|;"lens" (rtos (cdr (assoc 42 vt))))
  249.     (set_tile ;|MSG0|;"fclip" (rtos (cdr (assoc 43 vt))))
  250.     (set_tile ;|MSG0|;"bclip" (rtos (cdr (assoc 44 vt))))
  251.     (setq vdir (cdr (assoc 11 vt)))
  252.     ;; Stored in UCS
  253.     (if (= 1 wview)
  254.       (setq vdir (trans vdir 1 0 T))
  255.     )
  256.     (set_tile ;|MSG0|;"vdir_x" (rtos (car vdir)))
  257.     (set_tile ;|MSG0|;"vdir_y" (rtos (cadr vdir)))
  258.     (set_tile ;|MSG0|;"vdir_z" (rtos (caddr vdir)))
  259.  
  260.     (setq vmode (cdr (assoc 71 vt)))
  261.     (if (= (logand 1 vmode) 2) 
  262.       (set_tile "fclipon" "ACT")
  263.       (set_tile "fclipon" "DES")
  264.     )
  265.     (if (= (logand 1 vmode) 4) 
  266.       (set_tile "bclipon" "ACT")
  267.       (set_tile "bclipon" "DES")
  268.     )
  269.     (if (= (logand 1 vmode) 1) 
  270.       (progn 
  271.         (set_tile "persp" "ACT")
  272.         (if (= 1 wview)
  273.           (setq lab "Motivo (SCU)")
  274.           (setq lab "Motivo (SCP)")
  275.         )
  276.         (set_tile ;|MSG0|;"cen_tar" lab)
  277.         (setq vtar (cdr (assoc 12 vt)))
  278.         ;; Stored in WCS
  279.         (if (= 0 wview)               
  280.           (setq vtar (trans vtar 0 1))
  281.         )
  282.         (set_tile ;|MSG0|;"vtar_x" (rtos (car vtar)))
  283.         (set_tile ;|MSG0|;"vtar_y" (rtos (cadr vtar)))
  284.         (set_tile ;|MSG0|;"vtar_z" (rtos (caddr vtar)))
  285.       )  
  286.       (progn
  287.         (set_tile "persp" "DES")
  288.         (if (= 1 wview)
  289.           (setq lab "Centro (SCU)")
  290.           (setq lab "Centro (SCP)")
  291.         )
  292.         (set_tile ;|MSG0|;"cen_tar" lab)
  293.         (setq vtar (cdr (assoc 10 vt)))
  294.         ;; Stored in DCS
  295.         (if (= 1 wview)
  296.           (setq vtar (trans vtar 2 0))
  297.           (setq vtar (trans vtar 2 1))
  298.         )
  299.         (set_tile ;|MSG0|;"vtar_x" (rtos (car vtar)))
  300.         (set_tile ;|MSG0|;"vtar_y" (rtos (cadr vtar)))
  301.         (set_tile ;|MSG0|;"vtar_z" (rtos (caddr vtar)))
  302.       )
  303.     )
  304.   )
  305.   ;;
  306.   ;; Set up a variable that will be used when checking to see if a 
  307.   ;; selected view can be restored or not.  This variable is set
  308.   ;; once when the dialogue is called to minimise time wasted.
  309.   ;;
  310.   (defun what_space()
  311.     (cond
  312.       ;; If in pspace and there are no mspace viewports do not allow
  313.       ;; a mspace viewport to be resored.
  314.       ((and (= 0 (getvar "tilemode"))
  315.             (= 1 (getvar "cvport"))
  316.             (not (cdr (vports)))
  317.        )
  318.        (setq restorable ;|MSG0|;"no_mspace")
  319.       )
  320.       ;; If in mspace (either one), do not allow a pspace viewport to
  321.       ;; be restored.
  322.       ((or (= 1 (getvar "tilemode"))
  323.            (and (= 0 (getvar "tilemode"))
  324.                 (/= 1 (getvar "cvport"))
  325.            )
  326.        )
  327.        (setq restorable ;|MSG0|;"no_pspace")
  328.       )
  329.       (t (setq restorable nil))
  330.     )
  331.   )
  332.   ;;
  333.   ;;  This function checks the validity of a table item name.  If legitimate, 
  334.   ;;  the table item name is returned, nil otherwise.
  335.   ;;
  336.   (defun check_name (name)
  337.     (cond
  338.       ((not name) 
  339.         (set_tile "error" "No se permiten nombres de vista en blanco.")
  340.         nil
  341.       )
  342.       ((= "" new_view_name) 
  343.         (set_tile "error" "No se permiten nombres de vista en blanco.")
  344.         nil
  345.       )
  346.       ((not (snvalid name))
  347.         (set_tile "error" "Nombre de vista no vßlido. ")
  348.         nil
  349.       )
  350.       (t (set_tile ;|MSG0|;"error" "") name)
  351.     )
  352.   )
  353.   ;;
  354.   ;;  This function checks the validity of a table item name.  If legitimate, 
  355.   ;;  the table item name is returned, nil otherwise.
  356.   ;;
  357.   (defun check_name1 (name)
  358.     (cond
  359.       ((not (snvalid name))
  360.         (set_tile "error" "Nombre de vista no vßlido. ")
  361.         nil
  362.       )
  363.       (t (set_tile ;|MSG0|;"error" "") name)
  364.     )
  365.   )
  366.   ;;
  367.   ;; Adding a new view name.
  368.   ;; 
  369.   (defun save_view()
  370.     (setq new_view_name (xstrcase (ai_strtrim (get_tile ;|MSG0|;"new_view_name"))))
  371.     (cond 
  372.       ((not (check_name new_view_name)) (mode_tile ;|MSG0|;"new_view_name" 2))
  373.       ((and (= x1 x2)
  374.             (= y1 y2)
  375.        ) 
  376.        (set_tile "error" "Las esquinas de la ventana deben ser diferentes.")
  377.       )
  378.       ((and (or (member new_view_name init_list)
  379.                 (assoc new_view_name new_names)
  380.             )
  381.           (not (member new_view_name delete_list))
  382.            (no_redefine)       ; if T, the redefinition was cancelled.
  383.       ))
  384.       (t 
  385.         ;; If the new view to be defined already exists in the drawing
  386.         ;; then the name must be added to the delete list, in case the
  387.         ;; newly defined view is later deleted.
  388.         (if (member new_view_name init_list)
  389.           (progn 
  390.             (setq delete_list (cons new_view_name delete_list))          
  391.             (setq vnlist (append
  392.                             (reverse (cdr (member
  393.                                             new_view_name (reverse vnlist))))
  394.                             (cdr (member new_view_name vnlist))
  395.                          )
  396.             )
  397.             (setq lboxlist 
  398.                          (rm_item (what_pos new_view_name vnlist) lboxlist)
  399.             )
  400.           )
  401.         )
  402.         (if (assoc new_view_name new_names)
  403.           ;; remove new view name from new name list.
  404.           (progn 
  405.             (setq new_names 
  406.                   (append
  407.                      (reverse (cdr (member 
  408.                                      (assoc new_view_name new_names)
  409.                                      (reverse new_names)
  410.                      )))
  411.                      (cdr (member (assoc new_view_name new_names) new_names))
  412.                   )
  413.             )
  414.             (setq list_no (- (length vnlist) 
  415.                              (length (member new_view_name vnlist))
  416.             ))
  417.             (setq vnlist (rm_item list_no vnlist))
  418.             (setq lboxlist (rm_item list_no lboxlist))  
  419.           )
  420.         )
  421.         (if (= 1 which_save)
  422.           (setq new_names (append (list (list new_view_name)) new_names))
  423.           (setq new_names (append 
  424.                              (list (list new_view_name x1 y1 x2 y2))
  425.                              new_names
  426.                           )
  427.           )
  428.  
  429.         )
  430.         ;; Add *current* to the lists.
  431.         (if (= 1 (getvar "cvport"))
  432.           (setq viewtype "ESPACIOP")
  433.           (setq viewtype "ESPACIOM")
  434.         )
  435.         (setq vnlist (append vnlist (list new_view_name)))
  436.         (setq lboxlist 
  437.               (append lboxlist (list (strcat new_view_name "\t" viewtype)))
  438.         )
  439.         (if (>= (getvar "maxsort") (length vnlist))
  440.           (progn
  441.             (if vnlist (setq vnlist (acad_strlsort vnlist)))
  442.             (if lboxlist (setq lboxlist (acad_strlsort lboxlist)))
  443.           )
  444.         )
  445.         (done_dialog 1)
  446.         (setq new_view_name nil)      ; set the name to nil for the next time.
  447.       )
  448.     )
  449.   )
  450.   ;;
  451.   ;; Update View list.
  452.   ;;
  453.   (defun update_list()
  454.     (start_list ;|MSG0|;"list_view")
  455.     (mapcar 'add_list lboxlist)
  456.     (end_list)
  457.     (set_tile ;|MSG0|;"list_view" "0")
  458.     (setq picked_no "0")
  459.     (grey_des)
  460.   )
  461.   ;;
  462.   ;; If the new name already exists, inquire to overwrite it.
  463.   ;;
  464.   (defun no_redefine()
  465.     (if (not (new_dialog ;|MSG0|;"valert" dcl_id)) (exit))
  466.     (action_tile ;|MSG0|;"accept" "(done_dialog 1)")
  467.     (action_tile ;|MSG0|;"cancel" "(done_dialog 0)")
  468.     (if (= 0 (start_dialog)) t)       ; return T on Cancel
  469.   )      
  470.   ;;
  471.   ;; Pass a number and a list and recieve the list back with that item missing.
  472.   ;;
  473.   (defun rm_item (value the_list)
  474.     (setq temp_lisp_list '())
  475.     (setq j 0)
  476.     (foreach n the_list
  477.       (if (/= value j)
  478.         (setq temp_lisp_list (cons n temp_lisp_list))
  479.       )
  480.       (setq j (1+ j))
  481.     )
  482.     (setq temp_lisp_list (reverse temp_lisp_list))
  483.   )
  484.   ;;
  485.   ;; Delete view from list.
  486.   ;;
  487.   (defun delete()
  488.     (setq viewname (nth (atoi picked_no) vnlist))
  489.     (if (= viewname restore_view)
  490.       (progn 
  491.         (setq restore_view "*ACTUAL*")
  492.         (set_tile ;|MSG0|;"res_text" restore_view)
  493.       )
  494.     )
  495.         ;; When deleting an item that only exists on the new list then
  496.         ;; don't add it to the delete list.  Only add items to the
  497.         ;; delete list when they are not members of the new list and
  498.         ;; they are not members of the delete list already.
  499.         (if (assoc viewname new_names)
  500.           ;; remove new view name for new name list.
  501.           (setq new_names 
  502.                 (append
  503.                    (reverse (cdr (member 
  504.                                    (assoc viewname new_names)
  505.                                    (reverse new_names)
  506.                    )))
  507.                    (cdr (member (assoc viewname new_names) new_names))
  508.                 )
  509.           )
  510.           ;; only add it if it is not a member already and it is not
  511.           ;; a member of the new name list.
  512.           (if (not (member viewname delete_list))
  513.             (setq delete_list (cons viewname delete_list))
  514.           )
  515.         )
  516.         (setq vnlist (rm_item (atoi picked_no) vnlist))
  517.         (setq lboxlist (rm_item (atoi picked_no) lboxlist))  
  518.         (update_list)
  519.   )
  520.   ;;
  521.   ;; Disable the Describe button for *CURRENT* and new views.
  522.   ;;
  523.   (defun grey_des()
  524.     (setq viewname (nth (atoi picked_no) vnlist))
  525.     (setq lboxname (nth (atoi picked_no) lboxlist))
  526.     (if (= "*ACTUAL*" viewname)
  527.       (mode_tile ;|MSG0|;"delete" 1)
  528.       (mode_tile ;|MSG0|;"delete" 0)
  529.     )  
  530.     (cond 
  531.       ((and (= ;|MSG0|;"no_mspace" restorable)
  532.             (= "\tESPACIOM" (substr lboxname (- (strlen lboxname) 6)))
  533.        )
  534.         (mode_tile ;|MSG0|;"restore" 1)
  535.       )
  536.       ((and (= ;|MSG0|;"no_pspace" restorable)
  537.             (= "\tESPACIOP" (substr lboxname (- (strlen lboxname) 6)))
  538.        )
  539.         (mode_tile ;|MSG0|;"restore" 1)
  540.       )
  541.       (t 
  542.          (mode_tile ;|MSG0|;"restore" 0)
  543.       )
  544.     )
  545.   )
  546.   ;;
  547.   ;; Update text string to reflect current view to restore.
  548.   ;;
  549.   (defun restore ()
  550.     (setq restore_view (nth (atoi picked_no) vnlist))
  551.     (set_tile ;|MSG0|;"res_text" restore_view)
  552.   )
  553.   ;;
  554.   ;;  Creates a list of views in the drawing.
  555.   ;;
  556.   (defun make-lists(/ vname vlist flag lbname)
  557.     (setq vnlist nil lboxlist nil)
  558.     (setq vlist (tblnext ;|MSG0|;"view" T))
  559.     (while vlist
  560.       (setq vname (cdr (assoc 2 vlist)))
  561.       (setq flag (cdr (assoc 70 vlist)))
  562.       (if (= 1 (logand flag 1))
  563.           (setq viewtype "ESPACIOP")
  564.           (setq viewtype "ESPACIOM")
  565.       )
  566.           (setq lbname (strcat vname "\t" viewtype))
  567.           (setq vnlist (append vnlist (list vname)))
  568.           (setq lboxlist (append lboxlist (list lbname)))
  569.       (setq vlist (tblnext ;|MSG0|;"view"))
  570.     )
  571.  
  572.     ;; Add *CURRENT* to the lists.
  573.     (setq vnlist (append (list "*ACTUAL*") vnlist))
  574.     (setq lboxlist (append (list "*ACTUAL*") lboxlist))
  575.  
  576.     (setq init_list vnlist)           ; needed for checking purposes.
  577.  
  578.     (if (>= (getvar "maxsort") (length vnlist))
  579.       (progn
  580.         (if vnlist (setq vnlist (acad_strlsort vnlist)))
  581.         (if lboxlist (setq lboxlist (acad_strlsort lboxlist)))
  582.       )
  583.     )
  584.   )
  585.   ;;
  586.   ;;  Brings up the nested dialogue for creating new views.
  587.   ;;
  588.   (defun new_view()
  589.     (if (not (new_dialog ;|MSG0|;"new_view" dcl_id)) (exit))
  590.  
  591.     ;; Set up initial values.
  592.     (if (not which_save)
  593.       (progn
  594.         (setq which_save 1)
  595.       )
  596.     )
  597.  
  598.     (mode_tile ;|MSG0|;"new_view_name" 2)     ; set focus to the edit box.
  599.  
  600.     (if (= 1 which_save)
  601.       (set_tile ;|MSG0|;"r_current" "1")
  602.       (set_tile ;|MSG0|;"r_window" "1")
  603.     )
  604.  
  605.     (setq x1 (car x1y1))
  606.     (setq y1 (cadr x1y1))
  607.     (setq x2 (car x2y2))
  608.     (setq y2 (cadr x2y2))
  609.  
  610.     (set_tile ;|MSG0|;"x1_text" (rtos x1))
  611.     (set_tile ;|MSG0|;"y1_text" (rtos y1))
  612.     (set_tile ;|MSG0|;"x2_text" (rtos x2))
  613.     (set_tile ;|MSG0|;"y2_text" (rtos y2))
  614.  
  615.     (enable_rad which_save)
  616.  
  617.     (if new_view_name (set_tile ;|MSG0|;"new_view_name" new_view_name))
  618.  
  619.     ;; Set up actions.
  620.     (action_tile ;|MSG0|;"r_current" "(enable_rad 1)(setq which_save 1)")
  621.     (action_tile ;|MSG0|;"r_window" "(enable_rad 0)(setq which_save 0)")
  622.     (action_tile ;|MSG0|;"window" "(done_dialog 3)")
  623.     (action_tile ;|MSG0|;"save_view" "(save_view)")
  624.     (action_tile ;|MSG0|;"new_view_name" "(check_name1 (setq new_view_name $value))")
  625.  
  626.     (setq what_next1 (start_dialog))
  627.     (cond 
  628.       ((= 3 what_next1)
  629.        (done_dialog 2)
  630.       )
  631.       ((= 1 what_next1)
  632.        (update_list)
  633.       )
  634.       ((= 0 what_next1)
  635.        (setq new_view_name nil)
  636.       )
  637.     )
  638.   )
  639.   ;;
  640.   ;; Disable/Enable the controls when picking in the New View dialogue.
  641.   ;;
  642.   (defun enable_rad (value)
  643.     (mode_tile ;|MSG0|;"window" value)
  644.     (mode_tile ;|MSG0|;"fc" value)
  645.     (mode_tile ;|MSG0|;"oc" value)
  646.   )
  647.   ;;
  648.   ;; Put up the dialogue.
  649.   ;;
  650.   (defun ddview_main()
  651.  
  652.     (make-lists)                        ; Create the view lists.
  653.  
  654.     (what_space)
  655.  
  656.     (setq x1y1 (trans (getvar "vsmin") 1 2))
  657.     (setq x2y2 (trans (getvar "vsmax") 1 2))
  658.  
  659.     (setq x1 (car x1y1))
  660.     (setq y1 (cadr x1y1))
  661.     (setq x2 (car x2y2))
  662.     (setq y2 (cadr x2y2))
  663.  
  664.  
  665.     (setq what_next 5)
  666.     (setq what_next1 nil)
  667.     (while (< 1 what_next)      ; Loop necessary for hiding
  668.       (if (not (new_dialog ;|MSG0|;"view" dcl_id)) (exit))
  669.       ;; Put them in the list box.
  670.       (start_list ;|MSG0|;"list_view")
  671.       (mapcar 'add_list lboxlist)
  672.       (end_list)
  673.  
  674.       ;; Set up initial defaults.
  675.       (setq picked_no "0")
  676.       (set_tile ;|MSG0|;"list_view" "0")
  677.       (set_tile ;|MSG0|;"res_text" (nth (atoi picked_no) vnlist))   ; *current*
  678.       (mode_tile ;|MSG0|;"delete" 1)
  679.  
  680.       ;; Define action of widgets
  681.       (action_tile ;|MSG0|;"restore" "(restore)")
  682.       (action_tile ;|MSG0|;"save" "(st_save)")
  683.       (action_tile ;|MSG0|;"window" "(st_window)")
  684.       (action_tile ;|MSG0|;"delete" "(delete)")
  685.       (action_tile ;|MSG0|;"list_view" "(setq picked_no $value)(grey_des)")
  686.       (action_tile ;|MSG0|;"edit_view" "(vedit_act $value)")
  687.       (action_tile ;|MSG0|;"help" "(help \"\" \"ddview\")")
  688.       (action_tile ;|MSG0|;"describe" "(describe)")
  689.       (action_tile ;|MSG0|;"new_view" "(new_view)")
  690.       (cond
  691.         ((= what_next1 3)
  692.           (new_view)
  693.           (if (/= 3 what_next1) (setq what_next (start_dialog)))
  694.         )
  695.         (t (setq what_next (start_dialog)))
  696.       )
  697.       (cond 
  698.         ((= 2 what_next)
  699.           (initget 1)
  700.           (setq x1y1 (getpoint "\nPrimera esquina: "))
  701.           (initget 1)
  702.           (setq x2y2 (getcorner x1y1 "\nEsquina opuesta: "))
  703.         )
  704.       )
  705.     )
  706.     (if (= 1 what_next)
  707.       (progn 
  708.         (foreach n delete_list
  709.           (command "_.VIEW" "_D" n)
  710.         )
  711.         (foreach n new_names
  712.           (if (cdr n)
  713.             (command "_.VIEW" "_W" (car n) (list (nth 1 n) (nth 2 n)) 
  714.                                         (list (nth 3 n) (nth 4 n))
  715.             )
  716.             (command "_.VIEW" "_S" (car n))
  717.           )
  718.         )
  719.         ;; Only restore the view if it is not *CURRENT* or nil.
  720.         (if (not (or (not restore_view)
  721.                      (= restore_view "*ACTUAL*")
  722.             ))
  723.           (command "_.VIEW" "_R" restore_view)
  724.         )
  725.       )
  726.     )
  727.   )
  728.  
  729.   ;; Set up error function.
  730.   (setq old_cmd (getvar "cmdecho")    ; save current setting of cmdecho
  731.         old_error  *error*            ; save current error function
  732.         *error* ai_error              ; new error function
  733.   )
  734.  
  735.   (setvar "cmdecho" 0)
  736.  
  737.   (cond
  738.      (  (not (ai_notrans)))                       ; transparent not OK
  739.      (  (not (ai_acadapp)))                      ; ACADAPP.EXP xloaded?
  740.      (  (not (setq dcl_id (ai_dcl ;|MSG0|;"ddview"))))  ; is .DCL file loaded?
  741.      (t 
  742.         (ai_undo_push)
  743.         (ddview_main)                          ; proceed!
  744.         (ai_undo_pop)
  745.      )
  746.   )
  747.  
  748.   (setq *error* old_error) 
  749.   (setvar "cmdecho" old_cmd)
  750.   (princ)
  751. )
  752.  
  753. ;;;----------------------------------------------------------------------------
  754. (princ "  DDVIEW cargada.  ")
  755. (princ)
  756.  
  757.