home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 5.img / SUPPORT2.LIB / FILTER.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1993-02-10  |  71.1 KB  |  2,021 lines

  1. ;;;----------------------------------------------------------------------------
  2. ;;;   FILTER.LSP  ¬⌐Ñ╗ 0.5
  3. ;;;   ¬⌐┼v (C) 1991-1992  Autodesk ñ╜Ñq
  4. ;;;
  5. ;;;   Ñ╗│n┼ΘºK╢O¿╤▒z╢iªµÑ⌠ª≤Ñ╬│~╗▌¿D¬║½■¿⌐íB¡╫º∩ñ╬╡oªµ, ª²¼O░╚╜╨┐φ┤`ñU¡z
  6. ;;;   ¡∞½h :
  7. ;;;
  8. ;;;   1)  ñWªC¬║¬⌐┼v│qºi░╚╗▌ÑX▓{ªb¿Cñ@Ñ≈½■¿⌐∙╪íC
  9. ;;;   2)  ¼█├÷¬║╗í⌐·ñσÑ≤ñ]Ñ▓╢╖⌐·╕ⁿ¬⌐┼v│qºiñ╬Ñ╗╢╡│\Ñi│qºiíC
  10. ;;;
  11. ;;;   Ñ╗│n┼Θ╢╚┤ú¿╤º@¼░└│Ñ╬ñW¬║░╤ª╥, ª╙Ñ╝┴n⌐·⌐╬┴⌠ºtÑ⌠ª≤½O├╥; ╣∩⌐≤Ñ⌠ª≤»S«φ
  12. ;;;   Ñ╬│~ñº╛A║┘⌐╩, ÑHñ╬░╙╖~╛P░Γ⌐╥┴⌠ºtÑX¿π¬║½O├╥, ªbª╣ñ@╖ºñ⌐ÑHº_╗{íC
  13. ;;;
  14. ;;;
  15. ;;;----------------------------------------------------------------------------
  16. ;;;  DESCRIPTION
  17. ;;;
  18. ;;;  Dialogue front end to (ssget).  Allows customers to create, save and
  19. ;;;  apply filter lists for entity selection via a dialogue interface.
  20. ;;;  Uses FILTER.DCL.
  21. ;;;
  22. ;;;----------------------------------------------------------------------------
  23. ;;;
  24. ;;; ===========================================================================
  25. ;;; ===================== load-time error checking ============================
  26. ;;;
  27.  
  28.   (defun ai_abort (app msg)
  29.      (defun *error* (s)
  30.         (if old_error (setq *error* old_error))
  31.         (princ)
  32.      )
  33.      (if msg
  34.        (alert (strcat " └│Ñ╬╡{ªí┐∙╗~: "
  35.                       app
  36.                       " \n\n  "
  37.                       msg
  38.                       "  \n"
  39.               )
  40.        )
  41.      )
  42.      (exit)
  43.   )
  44.  
  45. ;;; Check to see if AI_UTILS is loaded, If not, try to find it,
  46. ;;; and then try to load it.
  47. ;;;
  48. ;;; If it can't be found or it can't be loaded, then abort the
  49. ;;; loading of this file immediately, preserving the (autoload)
  50. ;;; stub function.
  51.  
  52.   (cond
  53.      (  (and ai_dcl (listp ai_dcl)))          ; it's already loaded.
  54.  
  55.      (  (not (findfile "ai_utils.lsp"))                     ; find it
  56.         (ai_abort "FILTER"
  57.                   (strcat "ºΣñú¿∞íuAI_UTILS.LSPív└╔«╫;"
  58.                           "\n  ╜╨└╦¼díusupportívÑ╪┐²íC")))
  59.  
  60.      (  (eq "failed" (load "ai_utils" "failed"))            ; load it
  61.         (ai_abort "FILTER" "╡L¬k╕ⁿñJíuAI_UTILS.LSPív└╔«╫"))
  62.   )
  63.  
  64.   (if (not (ai_acadapp))               ; defined in AI_UTILS.LSP
  65.       (ai_abort "FILTER" nil)         ; a Nil <msg> supresses
  66.   )                                    ; ai_abort's alert box dialog.
  67.  
  68. ;;; ==================== end load-time operations ===========================
  69.  
  70. ;;;----------------------------------------------------------------------------
  71. ;;; The Main function.  Variables are initialised, and the dialogue box is
  72. ;;; prepared and activated.  A while loop is used to allow the dialogue box
  73. ;;; to be hidded for entity selection.
  74. ;;;----------------------------------------------------------------------------
  75. (defun c:filter(/
  76.              a                 edit_item         just_name      selection_list
  77.              add_to_list       edit_this         label          single_table
  78.              after_errno       enable_disable    lisp_error
  79.              all_lisp_list     entity_ename      lisp_pos       str1
  80.              appid_str         entity_lisp       list1          str2
  81.              bit_flag          entity_lisp_init  list_name      string
  82.              c1                entity_lisp_list  list_str       str_name
  83.              c2                entity_type       load_err       str_pos
  84.              check_color       error_msg         load_log       str_val
  85.              check_int         filter_main       lts
  86.              clear_list        filter_err        make_list      table_item
  87.              cmd               filter_gc         n              table_list
  88.              cnum              filter_lisp_list  n1             table_match
  89.              color_no          filter_list       name           table_name
  90.              current_filter    filter_nfl        named_lists    temp
  91.              current_line      filter_str_list   new_length     temp_lisp_list
  92.              dcl_id            f_err             new_lisp       temp_list
  93.              delete_list       gc_name           new_str        temp_ss
  94.                                                  nfl_lisp       temp_str
  95.                                                  nfl_str        the_list
  96.                                globals           olderr         title
  97.                                good_value        op             update
  98.                                                  ops_3          val
  99.                                                  pat            value
  100.                                                  pat_match      what_is_it
  101.                                                  pick           what_next
  102.                                                  pick_list
  103.                                                  poly_val       which_box
  104.                                                  pos            which_list
  105.                                                  pr             ws
  106.                                hmmm              redefine       x_op
  107.                                huh               remove         x_value
  108.                                i                 remove_flag    y_op
  109.                                init_lists        ri_ops         y_value
  110.                                                 rm_item        z_op
  111.                                item              rs_err         z_value
  112.                                item1             s
  113.                                item2             save_all
  114.              dp1               item_index        save_as
  115.              dp2               j                 select        ret_list
  116.              )
  117.   ;;
  118.   ;; Action on Add Selected Entity button.
  119.   ;;
  120.   (defun do_select_entity ()
  121.     (setq edit_item (atoi (get_tile "filter_str_list")))
  122.     (done_dialog 2)
  123.   )
  124.   ;;
  125.   ;; Action on Remove button.
  126.   ;;
  127.   (defun do_remove ()
  128.     (setq remove_flag 1)
  129.     (remove)
  130.     (setq remove_flag 0)
  131.   )
  132.   ;;
  133.   ;; Initialise the English list and corresponding group code list.  The list
  134.   ;; of operators is also initialised.
  135.   ;;
  136.   (defun init_lists()
  137.     (setq filter_list (list
  138.                         "Arc"          "Arc Center"         "Arc Radius"
  139.                         "Attribute"    "Attribute Position" "Attribute Tag"
  140.                         "Block"        "Block Name"         "Block Position"
  141.                                        "Block Rotation"
  142.                         "Circle"       "Circle Center"      "Circle Radius"
  143.                         "Color"
  144.                         "Dimension"    "Dimension Style"
  145.                         "Elevation"
  146.                         "Layer"
  147.                         "Line"         "Line Start"         "Line End"
  148.                         "Linetype"
  149.                         "Normal Vector"
  150.                         "Point"        "Point Position"
  151.                         "Polyline"
  152.                         "Shape"        "Shape Position"     "Shape Name"
  153.                         "Solid"        "Solid Point 1"      "Solid Point 2"
  154.                                        "Solid Point 3"      "Solid Point 4"
  155.                         "Text"         "Text Position"      "Text Value"
  156.                                        "Text Style Name"    "Text Height"
  157.                                        "Text Rotation"
  158.                         "Trace"        "Trace Point 1"      "Trace Point 2"
  159.                                        "Trace Point 3"      "Trace Point 4"
  160.                         "3dface"       "3dface Point 1"     "3dface Point 2"
  161.                                        "3dface Point 3"     "3dface Point 4"
  162.                         "Thickness"
  163.                         "Viewport"     "Viewport Center"
  164.                         "Xdata ID"
  165.                         "** Begin  AND"
  166.                         "** End    AND"
  167.                         "** Begin  OR"
  168.                         "** End    OR"
  169.                         "** Begin  XOR"
  170.                         "** End    XOR"
  171.                         "** Begin  NOT"
  172.                         "** End    NOT"
  173.                   )
  174.     )
  175.  
  176.     (setq filter_gc (list
  177.                          0 10 40
  178.                          0 10  2
  179.                          0  2 10 50
  180.                          0 10 40
  181.                          62
  182.                          0  3
  183.                          38
  184.                          8
  185.                          0 10 11
  186.                          6
  187.                          210
  188.                          0 10
  189.                          0
  190.                          0 10  2
  191.                          0 10 11 12 13
  192.                          0 10  1  7 40 50
  193.                          0 10 11 12 13
  194.                          0 10 11 12 13
  195.                          39
  196.                          0 10
  197.                          -3
  198.                          "<AND" "AND>"
  199.                          "<OR"  "OR>"
  200.                          "<XOR" "XOR>"
  201.                          "<NOT" "NOT>"
  202.         )
  203.     )
  204.     (setq ri_ops (list "=" "!=" "<" "<=" ">" ">=" "*"))
  205.   )
  206.   ;;
  207.   ;; Function to reset the error tile.
  208.   ;;
  209.   (defun rs_err()
  210.     (set_tile "error" "")
  211.   )
  212.   ;;
  213.   ;; Function called by SELECT button.  Used to bring the Color dialogue and
  214.   ;; the symbol table dialogues.
  215.   ;;
  216.   (defun select (/ current_filter selection_list color_no poly_val str
  217.                    table_name
  218.                 )
  219.     (setq current_filter (nth (atoi (get_tile "filter_by")) filter_list))
  220.     (cond
  221.       ((= "Color" current_filter)   ; if Color
  222.         (if (setq color_no (acad_colordlg 1 t))       ; and a color is selected
  223.           (set_tile "x_value" (itoa color_no))
  224.         )
  225.       )
  226.       (t (cond
  227.            ((= "Block Name"      current_filter) (setq table_name "Block"))
  228.            ((= "Dimension Style" current_filter) (setq table_name "Dimstyle"))
  229.            ((= "Layer"           current_filter) (setq table_name "Layer"))
  230.            ((= "Linetype"        current_filter) (setq table_name "Ltype"))
  231.            ((= "Text Style Name" current_filter) (setq table_name "Style"))
  232.            ((= "Xdata ID"  current_filter) (setq table_name "Appid"))
  233.            (t (princ "╢iªµíu┐∩╛▄ív«╔ª│╡{ªíñW¬║┐∙╗~"))
  234.          )
  235.          (if (setq selection_list (reverse (single_table table_name
  236.                    (strcat "┐∩╛▄íu" current_filter "ív" ))))
  237.            (progn
  238.              (setq n   0
  239.                    str "")
  240.              (while (< n (length selection_list))
  241.                (setq str (strcat (nth n selection_list) "," str))
  242.                (setq n (1+ n))
  243.              )
  244.              (set_tile "x_value" (substr str 1 (1- (strlen str))))
  245.            )
  246.         )
  247.       )
  248.     )
  249.   )
  250.   ;;
  251.   ;;  Deletes the current named list from the list of named lists.
  252.   ;;
  253.   (defun delete_list()
  254.     (if (/= 0 (setq pick_list (atoi (get_tile "named_lists"))))
  255.       (progn
  256.         (setq all_lisp_list (rm_item pick_list all_lisp_list))
  257.         (save_all)
  258.         (start_list "named_lists")
  259.         (mapcar 'add_list all_lisp_list)
  260.         (end_list)
  261.         (set_tile "named_lists" "0")
  262.         (setq filter_str_list ai_str|*unnamed)
  263.         (setq filter_lisp_list ai_lisp|*unnamed)
  264.         (start_list "filter_str_list")
  265.         (mapcar 'add_list filter_str_list)
  266.         (end_list)
  267.       )
  268.       (set_tile "error" "╡L¬kºR░úÑ╝¿πªW¬║íu┬o┬^▓M│µívíC")
  269.     )
  270.   )
  271.   ;;
  272.   ;; Retrieves the named lists from file. (NFL = Named Filter Lists)
  273.   ;;
  274.   (defun load_log(/ filter_nfl nfl_lisp nfl_str current_line)
  275.     (if (setq filter_nfl (open "filter.nfl" "r"))
  276.       (progn
  277.         (setq current_line (read-line filter_nfl))
  278.         (while (and (/= "" current_line)
  279.                     (/= nil current_line)
  280.                     (/= ":" (substr current_line 1 1))) ; skip comments
  281.          (setq current_line (read-line filter_nfl))
  282.         )
  283.         (while current_line                       ; get lisp
  284.           (setq name (substr current_line 10))     ; get list name
  285.           (setq all_lisp_list (cons name all_lisp_list))
  286.           (setq current_line (read-line filter_nfl))
  287.           (while (/= ":" (substr current_line 1 1))
  288.             (setq nfl_lisp (cons (read current_line) nfl_lisp))
  289.             (setq current_line (read-line filter_nfl))
  290.           )
  291.           (set (read (strcat "ai_lisp|" name)) (reverse nfl_lisp))
  292.           (setq nfl_lisp '())
  293.           (setq current_line (read-line filter_nfl))         ; get str
  294.           (set (read (strcat "ai_str|" name)) '())
  295.           (while (and current_line (/= ":" (substr current_line 1 1)))
  296.             (setq nfl_str (cons current_line nfl_str))
  297.             (setq current_line (read-line filter_nfl))
  298.           )
  299.           (set (read (strcat "ai_str|" name)) (reverse (cons "" nfl_str)))
  300.           (setq nfl_str '())
  301.         )
  302.         (if (and all_lisp_list
  303.                  (< (length all_lisp_list) (getvar "maxsort"))
  304.             )
  305.           (setq all_lisp_list (acad_strlsort all_lisp_list))
  306.         )
  307.         (start_list "named_lists")
  308.         (mapcar 'add_list all_lisp_list)
  309.         (end_list)
  310.         (set_tile "named_lists" "0")
  311.       )
  312.     )
  313.   )
  314.   ;;
  315.   ;;  Saves named lists to file.
  316.   ;;
  317.   (defun save_all(/ filter_nfl)
  318.     (if (setq filter_nfl (open "filter.nfl" "w"))
  319.       (progn
  320.         (write-line "Filter.nfl í╨ ╜╨ñ┼╜s┐Φª╣└╔«╫íC" filter_nfl)
  321.         (if (< 1 (length all_lisp_list))
  322.           (progn
  323.             (foreach n all_lisp_list
  324.               (if (/= n "*unnamed")
  325.                 (progn
  326.                   (write-line (strcat ":ai_lisp|" n) filter_nfl)
  327.                   (foreach n1
  328.                     (reverse (lts (eval (read (strcat "ai_lisp|" n))) 1))
  329.                     (write-line n1 filter_nfl)
  330.                   )
  331.                   (write-line (strcat ":ai_str|" n) filter_nfl)
  332.                   (foreach n1 (eval (read (strcat "ai_str|" n)))
  333.                     (if (/= "" n1) (write-line n1 filter_nfl))
  334.                   )
  335.                 )
  336.               )
  337.             )
  338.           )
  339.         )
  340.         (close filter_nfl)
  341.       )
  342.       (alert (strcat "╡L¬k▒Níu┬o┬^▓M│µívªs└╔\n"
  343.                      " í╨ ╢╖╛╓ª│ª╣Ñ╪┐²¬║íu╝gñJñ╣╖╟ívíC"
  344.              )
  345.       )
  346.     )
  347.   )
  348.   ;;
  349.   ;; If not the *unnamed list, make current the selected one.
  350.   ;;
  351.   (defun named_lists()
  352. ;    (cond
  353. ;      ((/= "0" (get_tile "named_lists"))
  354.         (setq list_name (nth (atoi (get_tile "named_lists")) all_lisp_list))
  355.         (setq filter_lisp_list
  356.               (eval (read
  357.                       (strcat "ai_lisp|" list_name)
  358.               ))
  359.         )
  360.         (setq filter_str_list
  361.               (eval (read
  362.                       (strcat "ai_str|" list_name)
  363.               ))
  364.         )
  365.         (start_list "filter_str_list")
  366.         (mapcar 'add_list filter_str_list)
  367.         (end_list)
  368. ;      )
  369. ;    )
  370.   )
  371.  
  372.   ;;
  373.   ;; Check the entered name and if valid, save it.
  374.   ;;
  375.   (defun save_as()
  376.     (setq list_name (ai_strtrim (get_tile "new_name")))
  377.     (cond
  378.       ((or (= nil list_name)(= "" list_name))
  379.         (set_tile "error" "ñú▒╡¿ⁿíuNullív┬o┬^ªW║┘íC")
  380.       )
  381.       ((wcmatch list_name "*[]`#`@`.`?`*`~`[`,`'!%^&()+={}|`\\:;\"<>/]*")
  382.         (set_tile "error" "íu┬o┬^ªW║┘ív▒aª│╡L«─ªr▓┼íC")
  383.       )
  384.       ((= "*unnamed" list_name)
  385.         (set_tile "error" "íu┬o┬^ªW║┘ív╡L«─íC")
  386.       )
  387.       ((and (member list_name all_lisp_list) (not (redefine))))
  388.       ((lisp_error))
  389.       (T
  390.         (set (read (eval (strcat "ai_lisp|" list_name))) filter_lisp_list)
  391.         (set (read (eval (strcat "ai_str|" list_name))) filter_str_list)
  392.         (if (not (member list_name all_lisp_list)) ; add if not member
  393.           (progn
  394.             (setq all_lisp_list (cons list_name all_lisp_list))
  395.             (if (and all_lisp_list
  396.                      (< (length all_lisp_list) (getvar "maxsort"))
  397.                 )
  398.               (setq all_lisp_list (acad_strlsort all_lisp_list))
  399.             )
  400.           )
  401.         )
  402.         (start_list "named_lists")
  403.         (mapcar 'add_list all_lisp_list)
  404.         (end_list)
  405.         (set_tile "named_lists" (itoa (what_pos list_name all_lisp_list)))
  406.         (save_all)
  407.       )
  408.     )
  409.   )
  410.   ;;
  411.   ;; If the entered name for the filter list matches an existing name, call
  412.   ;; dialogue for confirmation to redefine it.  T is returned if OK to redefine.
  413.   ;;
  414.   (defun redefine ()
  415.     (if (not (new_dialog "already_exists" dcl_id)) (exit))
  416.     (action_tile "redefine" "(done_dialog 2)")
  417.     (action_tile "cancel" "(done_dialog 0)")
  418.     (if (= (start_dialog) 2) t)           ; return t on Redefine, nil on cancel
  419.   )
  420.   ;;
  421.   ;; Debugging routine.
  422.   ;;
  423.   (defun pr()
  424.     (princ filter_str_list)
  425.     (princ filter_lisp_list)
  426.   )
  427.   ;;
  428.   ;;  Routine that updates the current English and Lisp lists to contain the
  429.   ;;  new English and Lisp arguments.
  430.   ;;
  431.   (defun update (new_str new_lisp / str1 str2 i edit_this lisp_pos temp_str)
  432.     ; find current position in filter_lisp_list (list of lists)
  433.     (setq i -1)
  434.     (setq edit_this -1)        ; corresponding item in lisp list.
  435.     (setq lisp_pos -1)         ; so that length below occurs
  436.     (if filter_lisp_list
  437.       (progn
  438.         (while (< edit_this str_pos)  ; until they are equal
  439.           (setq i (1+ i))
  440.           (if (not (and (= -4 (car (nth i filter_lisp_list)))
  441.                        (not (member
  442.                               (cdr (nth i filter_lisp_list))
  443.                               '("<AND" "AND>" "<OR"  "OR>"
  444.                                "<XOR" "XOR>" "<NOT" "NOT>")
  445.                             )
  446.                        )
  447.                    )
  448.               )
  449.             (progn
  450.               (setq edit_this (1+ edit_this))
  451.             )
  452.           )
  453.         )
  454.         (if (and (< 0 i)
  455.                  (and (= -4 (car (nth (1- i) filter_lisp_list)))
  456.                       (not (member
  457.                              (cdr (nth (1- i) filter_lisp_list))
  458.                              '("<AND" "AND>" "<OR"  "OR>"
  459.                                "<XOR" "XOR>" "<NOT" "NOT>")
  460.                            )
  461.                       )
  462.                  )
  463.             )
  464.           (setq lisp_pos (1- i))
  465.           (setq lisp_pos i)
  466.         )
  467.       )
  468.     )
  469.     ; join lisp lists
  470.     (setq i 0)
  471.     (setq str1 '()) (setq str2 '())
  472.     (if (<= 0 lisp_pos)
  473.       (progn
  474.         (while (< i lisp_pos)
  475.           (setq str1 (cons (nth i filter_lisp_list) str1))
  476.           (setq i (1+ i))
  477.         )
  478.         (setq str1 (reverse str1))
  479.         (setq temp_str (reverse filter_lisp_list))
  480.         (setq i 0)
  481.         (while (<= i (- (- (length filter_lisp_list) lisp_pos) 1))
  482.           (setq str2 (cons (nth i temp_str) str2))
  483.           (setq i (1+ i))
  484.         )
  485.       )
  486.     )
  487.     (setq filter_lisp_list (append str1 new_lisp str2))
  488.     (setq ai_lisp|*unnamed filter_lisp_list)
  489.     ; join string lists
  490.     (setq i 0)
  491.     (setq str1 '()) (setq str2 '())
  492.     (while (< i str_pos)
  493.       (setq str1 (cons (nth i filter_str_list) str1))
  494.       (setq i (1+ i))
  495.     )
  496.     (setq str1 (reverse str1))
  497.     (setq temp_str (reverse filter_str_list))
  498.     (setq i 0)
  499.     (while (<= i (- (- (length filter_str_list) str_pos) 1))
  500.       (setq str2 (cons (nth i temp_str) str2))
  501.       (setq i (1+ i))
  502.     )
  503.     (setq filter_str_list (append str1 new_str str2))
  504.     (setq ai_str|*unnamed filter_str_list)
  505.     ; Update displayed string list
  506.     (start_list "filter_str_list")
  507.     (mapcar 'add_list filter_str_list)
  508.     (end_list)
  509.  
  510.     (setq new_length (length new_str))   ; length of new string list.
  511.     (cond
  512.      ((/= (1- (length filter_str_list)) str_pos)
  513.        (set_tile "filter_str_list"
  514.                  (itoa (setq str_pos (+ str_pos new_length)))
  515.        )
  516.      )
  517.      ((and (= (1- (length filter_str_list)) str_pos)
  518.            (/= 1 (length filter_str_list))
  519.       )
  520.        (set_tile "filter_str_list" (itoa (1- str_pos)))
  521.      )
  522.      (T)
  523.     )
  524.   )
  525.   ;;
  526.   ;; Disables the controls when an filter is chosen from the list of possible
  527.   ;; filters
  528.   ;;
  529.   (defun grey_filter ( )
  530.     (setq pick (nth (atoi (get_tile "filter_by")) filter_list))
  531.     (enable_disable pick)
  532.   )
  533.   ;;
  534.   ;; Disables the controls according to current selection.
  535.   ;;
  536.   (defun enable_disable(string)
  537.     (cond
  538.       ((member string '(
  539.                       "Arc"   "Attribute" "Block" "Circle" "Dimension" "Line"
  540.                       "Point" "Polyline"  "Shape"  "Solid"  "Trace"    "3dface"
  541.                       "Viewport"
  542.                        "** Begin  AND" "** End    AND"
  543.                        "** Begin  OR"  "** End    OR"
  544.                        "** Begin  XOR" "** End    XOR"
  545.                        "** Begin  NOT" "** End    NOT"
  546.        ))
  547.        (mode_tile "x_op" 1) (mode_tile "x_value" 1) (mode_tile "x_text" 1)
  548.        (mode_tile "y_op" 1) (mode_tile "y_value" 1) (mode_tile "y_text" 1)
  549.        (mode_tile "z_op" 1) (mode_tile "z_value" 1) (mode_tile "z_text" 1)
  550.        (mode_tile "select" 1)
  551.       )
  552.       ((member string '(
  553.                        "Arc Center"
  554.                        "Attribute Position"
  555.                        "Block Position"
  556.                        "Circle Center"
  557.                        "Line Start"          "Line End"
  558.                        "Point Position"
  559.                        "Shape Position"
  560.                        "Solid Point 1"       "Solid Point 2"   "Solid Point 3"
  561.                        "Solid Point 4"
  562.                        "Text Position"
  563.                        "Trace Point 1"       "Trace Point 2"   "Trace Point 3"
  564.                        "Trace Point 4"
  565.                        "3dface Point 1"      "3dface Point 2"  "3dface Point 3"
  566.                        "3dface Point 4"
  567.                        "Viewport Center"
  568.                        )
  569.        )
  570.         (mode_tile "x_op" 0) (mode_tile "x_value" 0) (mode_tile "x_text" 0)
  571.         (mode_tile "y_op" 0) (mode_tile "y_value" 0) (mode_tile "y_text" 0)
  572.         (mode_tile "z_op" 0) (mode_tile "z_value" 0) (mode_tile "z_text" 0)
  573.         (mode_tile "select" 1)
  574.       )
  575.       ((member string '(
  576.                        "Elevation" "Thickness"
  577.                        "Arc Radius"
  578.                        "Block X Scale"   "Block Y Scale" "Block Z Scale"
  579.                        "Block Rotation"
  580.                        "Circle Radius"
  581.                        "Text Height"     "Text Rotation"
  582.                        )
  583.        )
  584.         (mode_tile "x_op" 0) (mode_tile "x_value" 0) (mode_tile "x_text" 0)
  585.         (mode_tile "y_op" 1) (mode_tile "y_value" 1) (mode_tile "y_text" 1)
  586.         (mode_tile "z_op" 1) (mode_tile "z_value" 1) (mode_tile "z_text" 1)
  587.         (mode_tile "select" 1)
  588.       )
  589.       ((member string '(
  590.                        "Color"
  591.                        )
  592.        )
  593.         (mode_tile "x_op" 0) (mode_tile "x_value" 0) (mode_tile "x_text" 0)
  594.         (mode_tile "y_op" 1) (mode_tile "y_value" 1) (mode_tile "y_text" 1)
  595.         (mode_tile "z_op" 1) (mode_tile "z_value" 1) (mode_tile "z_text" 1)
  596.         (mode_tile "select" 0)
  597.       )
  598.       ((member string '(
  599.                        "Dimension Type"
  600.                        "Polyline Flags" "Viewport Status"
  601.                        )
  602.        )
  603.         (mode_tile "x_op" 0) (mode_tile "x_value" 0) (mode_tile "x_text" 0)
  604.         (mode_tile "y_op" 1) (mode_tile "y_value" 1) (mode_tile "y_text" 1)
  605.         (mode_tile "z_op" 1) (mode_tile "z_value" 1) (mode_tile "z_text" 1)
  606.         (mode_tile "select" 1)
  607.       )
  608.       ((member string '(
  609.                        "Attribute Tag"
  610.                        "Text Value"
  611.                        "Shape Name"
  612.                        )
  613.        )
  614.         (mode_tile "x_op" 1) (mode_tile "x_value" 0) (mode_tile "x_text" 0)
  615.         (mode_tile "y_op" 1) (mode_tile "y_value" 1) (mode_tile "y_text" 1)
  616.         (mode_tile "z_op" 1) (mode_tile "z_value" 1) (mode_tile "z_text" 1)
  617.         (mode_tile "select" 1)
  618.       )
  619.       ((member string '(
  620.                        "Block Name"
  621.                        "Dimension Style"
  622.                        "Layer"
  623.                        "Linetype"
  624.                        "Text Style Name"
  625.                        "Xdata ID"
  626.                        )
  627.        )
  628.         (mode_tile "x_op" 1) (mode_tile "x_value" 0) (mode_tile "x_text" 0)
  629.         (mode_tile "y_op" 1) (mode_tile "y_value" 1) (mode_tile "y_text" 1)
  630.         (mode_tile "z_op" 1) (mode_tile "z_value" 1) (mode_tile "z_text" 1)
  631.         (mode_tile "select" 0)
  632.       )
  633.       ((member string '(
  634.                        "Normal Vector"
  635.                        )
  636.        )
  637.         (mode_tile "x_op" 0) (mode_tile "x_value" 0) (mode_tile "x_text" 0)
  638.         (mode_tile "y_op" 1) (mode_tile "y_value" 0) (mode_tile "y_text" 0)
  639.         (mode_tile "z_op" 1) (mode_tile "z_value" 0) (mode_tile "z_text" 0)
  640.         (mode_tile "select" 1)
  641.       )
  642.     )
  643.   )
  644.   ;;
  645.   ;; Add the selected filter, operator, and value to list.
  646.   ;;
  647.   (defun add_to_list (/ gc_name op val str_val)
  648.     (setq str_pos (atoi (get_tile "filter_str_list")))  ; item in string list.
  649.     (setq op nil)(setq val nil)(setq str_val nil)
  650.     (setq gc_name (nth (atoi (get_tile "filter_by")) filter_list))
  651.     (cond
  652.       ((member gc_name '(
  653.                         "Arc Center"
  654.                         "Attribute Position"
  655.                         "Block Position"
  656.                         "Circle Center"
  657.                         "Line Start"         "Line End"
  658.                         "Point Position"
  659.                         "Shape Position"
  660.                         "Solid Point 1"      "Solid Point 2"   "Solid Point 3"
  661.                         "Solid Point 4"
  662.                         "Text Position"
  663.                         "Trace Point 1"      "Trace Point 2"   "Trace Point 3"
  664.                         "Trace Point 4"
  665.                         "3dface Point 1"     "3dface Point 2"  "3dface Point 3"
  666.                         "3dface Point 4"
  667.                         "Viewport Center"
  668.                         )
  669.        )
  670.         (setq op (cons -4 (strcat
  671.                             (setq x_op (nth (atoi (get_tile "x_op")) ri_ops))
  672.                             ","
  673.                             (setq y_op (nth (atoi (get_tile "y_op")) ri_ops))
  674.                             ","
  675.                             (setq z_op (nth (atoi (get_tile "z_op")) ri_ops))
  676.                            )
  677.                   )
  678.         )
  679.         (cond
  680.           ((not (setq x_value
  681.                       (ai_num (get_tile "x_value") "íuX «y╝╨ív╡L«─íC" 0)
  682.                 )
  683.            )
  684.            (mode_tile "x_value" 2)
  685.           )
  686.           ((not (setq y_value
  687.                       (ai_num (get_tile "y_value") "íuY «y╝╨ív╡L«─íC" 0)
  688.                 )
  689.            )
  690.            (mode_tile "y_value" 2)
  691.           )
  692.           ((not (setq z_value
  693.                       (ai_num (get_tile "z_value") "íuZ «y╝╨ív╡L«─íC" 0)
  694.                 )
  695.            )
  696.            (mode_tile "z_value" 2)
  697.           )
  698.           (T (setq val
  699.                    (list
  700.                          (nth (what_pos gc_name filter_list) filter_gc)
  701.                          x_value
  702.                          y_value
  703.                          z_value
  704.                    )
  705.              )
  706.              (setq str_val (strcat gc_name "\tX\t" x_op "\t" (rtos x_value)
  707.                                            "\tY\t" y_op "\t" (rtos y_value)
  708.                                            "\tZ\t" z_op "\t" (rtos z_value)
  709.                            )
  710.              )
  711.           )
  712.         )
  713.       )
  714.       ((member gc_name '("Normal Vector"))
  715.         (setq op (cons -4 (setq x_op (nth (atoi (get_tile "x_op")) ri_ops))))
  716.         (cond
  717.           ((not (setq x_value
  718.                       (ai_num (get_tile "x_value") "íuX «y╝╨ív╡L«─íC" 0)
  719.                 )
  720.            )
  721.            (mode_tile "x_value" 2)
  722.           )
  723.           ((not (setq y_value
  724.                       (ai_num (get_tile "y_value") "íuY «y╝╨ív╡L«─íC" 0)
  725.                 )
  726.            )
  727.            (mode_tile "y_value" 2)
  728.           )
  729.           ((not (setq z_value
  730.                       (ai_num (get_tile "z_value") "íuZ «y╝╨ív╡L«─íC" 0)
  731.                 )
  732.            )
  733.            (mode_tile "z_value" 2)
  734.           )
  735.           (T (setq val (list
  736.                              (nth (what_pos gc_name filter_list) filter_gc)
  737.                              x_value
  738.                              y_value
  739.                              z_value
  740.                        )
  741.              )
  742.              (setq str_val (strcat gc_name     "\tX\t" x_op "\t" (rtos x_value)
  743.                                                "\tY\t" x_op "\t" (rtos y_value)
  744.                                                "\tZ\t" x_op "\t" (rtos z_value)
  745.                            )
  746.              )
  747.           )
  748.         )
  749.       )
  750.       ((member gc_name '(
  751.                           "Elevation" "Thickness"
  752.                           "Arc Radius"
  753.                           "Block X Scale"   "Block Y Scale" "Block Z Scale"
  754.                           "Circle Radius"
  755.                           "Text Height"
  756.                         )
  757.        )
  758.         (setq op (cons -4 (setq x_op (nth (atoi (get_tile "x_op")) ri_ops))))
  759.         (cond
  760.           ((not (setq x_value
  761.                       (ai_num (get_tile "x_value") "íu╝╞¡╚ív╡L«─íC" 0)
  762.                 )
  763.            )
  764.            (mode_tile "x_value" 2)
  765.           )
  766.           (T (setq val
  767.                    (cons (nth (what_pos gc_name filter_list) filter_gc)
  768.                          x_value
  769.                    )
  770.              )
  771.              (setq str_val (strcat gc_name  "\t\t" x_op "\t" (rtos x_value)))
  772.           )
  773.         )
  774.       )
  775.       ((member gc_name '(
  776.                           "Block Rotation"
  777.                           "Text Rotation"
  778.                         )
  779.        )
  780.         (setq op (cons -4 (setq x_op (nth (atoi (get_tile "x_op")) ri_ops))))
  781.         (cond
  782.           ((not (setq x_value
  783.                       (ai_angle (get_tile "x_value") "íu¿ñ½╫ív╡L«─íC")
  784.                 )
  785.            )
  786.            (mode_tile "x_value" 2)
  787.           )
  788.           (T (setq val
  789.                    (cons (nth (what_pos gc_name filter_list) filter_gc)
  790.                          x_value
  791.                    )
  792.              )
  793.              (setq str_val (strcat gc_name  "\t\t" x_op "\t" (rtos x_value)))
  794.           )
  795.         )
  796.       )
  797.       ((member gc_name '(
  798.                          "Color"
  799.                         )
  800.        )
  801.         (setq op (cons -4 (setq x_op (nth (atoi (get_tile "x_op")) ri_ops))))
  802.         (cond
  803.           ((not (setq x_value
  804.                       (check_color (get_tile "x_value"))
  805.                 )
  806.            )
  807.            (mode_tile "x_value" 2)
  808.           )
  809.           (T (setq val
  810.                    (cons (nth (what_pos gc_name filter_list) filter_gc)
  811.                          x_value
  812.                    )
  813.              )
  814.              (cond
  815.                ((= 0 x_value)   (setq x_value "0 - By Block"))
  816.                ((= 1 x_value)   (setq x_value "1 - Red"))
  817.                ((= 2 x_value)   (setq x_value "2 - Yellow"))
  818.                ((= 3 x_value)   (setq x_value "3 - Green"))
  819.                ((= 4 x_value)   (setq x_value "4 - Cyan"))
  820.                ((= 5 x_value)   (setq x_value "5 - Blue"))
  821.                ((= 6 x_value)   (setq x_value "6 - Magenta"))
  822.                ((= 7 x_value)   (setq x_value "7 - White"))
  823.                ((= 256 x_value) (setq x_value "256 - By Layer"))
  824.                (t (setq x_value (itoa x_value)))
  825.              )
  826.              (setq str_val (strcat gc_name "\t\t" x_op "\t" x_value))
  827.           )
  828.         )
  829.       )
  830.       ((member gc_name '(
  831.                           "Attribute Tag" "Block Name"
  832.                           "Dimension Style"
  833.                           "Layer" "Linetype"
  834.                           "Shape Name"
  835.                           "Text Value" "Text Style Name"
  836.                         )
  837.        )
  838.         (cond
  839.           ((= "" (setq x_value (ai_strtrim (get_tile "x_value"))))
  840.             (mode_tile "x_value" 2)
  841.           )
  842.           (T (setq val
  843.                    (cons (nth (what_pos gc_name filter_list) filter_gc)
  844.                          x_value
  845.                    )
  846.              )
  847.              (setq str_val (strcat gc_name "\t\t=\t" x_value))
  848.           )
  849.         )
  850.       )
  851.       ((member gc_name '("Xdata ID"))
  852.         (cond
  853.           ((= "" (setq x_value (ai_strtrim (get_tile "x_value"))))
  854.             (mode_tile "x_value" 2)
  855.           )
  856.           (T (setq val
  857.                      (cons
  858.                        (nth (what_pos gc_name filter_list) filter_gc)
  859.                        (list (list x_value))
  860.                      )
  861.              )
  862.              (setq str_val (strcat gc_name "\t\t=\t" x_value))
  863.           )
  864.         )
  865.       )
  866.       ((member gc_name '(
  867.                         "Arc"   "Circle" "Dimension" "Line"
  868.                         "Point" "Polyline"  "Shape"  "Solid"  "Text" "Trace"
  869.                         "3dface" "Viewport"
  870.                         )
  871.        )
  872.         (setq val (cons 0 gc_name))
  873.         (setq str_val (strcat "╣╧ñ╕         \t\t=\t" gc_name))
  874.       )
  875.       ((member gc_name '(
  876.                          "Attribute"
  877.                         )
  878.        )
  879.         (setq val (cons 0 "ATTDEF"))
  880.         (setq str_val (strcat "╣╧ñ╕         \t\t=\t" gc_name))
  881.       )
  882.       ((member gc_name '(
  883.                          "Block"
  884.                         )
  885.        )
  886.         (setq val (cons 0 "INSERT"))
  887.         (setq str_val (strcat "╣╧ñ╕         \t\t=\t" gc_name))
  888.       )
  889.       ((member gc_name '(
  890.                         "** Begin  AND"  "** End    AND"
  891.                         "** Begin  OR"   "** End    OR"
  892.                         "** Begin  XOR"  "** End    XOR"
  893.                         "** Begin  NOT"  "** End    NOT"
  894.                         )
  895.        )
  896.         (setq val (cons -4  (nth (what_pos gc_name filter_list) filter_gc)))
  897.         (setq str_val (strcat gc_name "\t"))
  898.       )
  899.       (T)
  900.     )
  901.     (cond
  902.       ((and op val str_val)
  903.         (update (list str_val) (list op val))
  904.         (set_tile "named_lists" "0")
  905.       )
  906.       ((and val str_val)
  907.         (update (list str_val) (list val))
  908.         (set_tile "named_lists" "0")
  909.       )
  910.       (T)
  911.     )
  912.   )
  913.   ;;
  914.   ;; Check if value passed is a valid color integer.  If valid, return the
  915.   ;; integer, else nil.
  916.   ;;
  917.   (defun check_color(value)
  918.     (if (or (wcmatch value "*@*,*.*")  ;  alphabetic or nonalphanumeric.
  919.              (>  0 (distof value))
  920.              (<  256 (distof value))
  921.         )
  922.       (progn (set_tile "error" "íu├CªΓ╜Xív╡L«─íC") nil)
  923.       (atoi value)
  924.     )
  925.   )
  926.   ;;
  927.   ;; Check if value passed is an integer.  If valid, return the integer, else
  928.   ;; nil.
  929.   ;;
  930.   (defun check_int(value)
  931.     (if (and (wcmatch value "*@*,*.*")  ;
  932.              (<= 0 value)
  933.              (<  256 value))
  934.       (progn (set_tile "error" "íu├CªΓ╜Xív╡L«─íC") nil)
  935.       (atoi value)
  936.     )
  937.   )
  938.   ;;
  939.   ;; Pass an item and a list and recieve a number showing it's position in
  940.   ;; the list, nil otherwise.  Item must be in the list, and the list must
  941.   ;; contain unique names. 0 if first item.
  942.   ;;
  943.   (defun what_pos (item the_list / pos)
  944.     (setq pos (- (length the_list)
  945.                  (length (member item the_list)))
  946.     )
  947.   )
  948.   ;;
  949.   ;; Remove item from English and Lisp lists.
  950.   ;;
  951.   (defun remove()
  952.     (setq str_pos (atoi (get_tile "filter_str_list")))  ; item in string list.
  953.     (if (/= (1- (length filter_str_list)) str_pos) ; don't remove the blank
  954.       (progn
  955.         ; strip 1 item from string list
  956.         (setq filter_str_list (rm_item str_pos filter_str_list))
  957.         (setq ai_str|*unnamed filter_str_list)
  958.         (setq i -1)
  959.         (setq edit_this -1)        ; corresponding item in lisp list.
  960.         (while (< edit_this str_pos)  ; until they are equal
  961.           (setq i (1+ i))
  962.           (if (not (and (= -4 (car (nth i filter_lisp_list)))
  963.                         (not (member (cdr (nth i filter_lisp_list))
  964.                                   '("<AND" "AND>" "<OR"  "OR>"
  965.                                     "<XOR" "XOR>" "<NOT" "NOT>")
  966.                              )
  967.                         )
  968.                    )
  969.               )
  970.             (setq edit_this (1+ edit_this))
  971.           )
  972.         )
  973.         (setq filter_lisp_list (rm_item i filter_lisp_list))
  974.         (setq ai_lisp|*unnamed filter_lisp_list)
  975.         (set_tile "named_lists" "0")
  976.         (if (and (< 0 i)
  977.                  (and (= -4 (car (nth (1- i) filter_lisp_list)))
  978.                       (not (member (cdr (nth (1- i) filter_lisp_list))
  979.                                   '("<AND" "AND>" "<OR"  "OR>"
  980.                                     "<XOR" "XOR>" "<NOT" "NOT>")
  981.                            )
  982.                       )
  983.                  )
  984.             )
  985.           (progn
  986.             (setq filter_lisp_list (rm_item (1- i) filter_lisp_list))
  987.             (setq ai_lisp|*unnamed filter_lisp_list)
  988.           )
  989.         )
  990.         (if (= 1 remove_flag)   ; only redisplay if remove, not with substitute
  991.           (progn
  992.             (start_list "filter_str_list")
  993.             (mapcar 'add_list filter_str_list)
  994.             (end_list)
  995.             ;; set highlight after removing item unless it's a blank list.
  996.             (cond
  997.               ((/= (1- (length filter_str_list)) str_pos)
  998.                 (set_tile "filter_str_list" (itoa str_pos))
  999.               )
  1000.               ((and (= (1- (length filter_str_list)) str_pos)
  1001.                     (/= 1 (length filter_str_list))
  1002.                )
  1003.                 (set_tile "filter_str_list" (itoa (1- str_pos)))
  1004.               )
  1005.               (T)
  1006.             )
  1007.           )
  1008.         )
  1009.       )
  1010.     )
  1011.   )
  1012.   ;;
  1013.   ;; Pass a number and a list and recieve the list back with that item missing.
  1014.   ;;
  1015.   (defun rm_item (value the_list)
  1016.     (setq temp_lisp_list '())
  1017.     (setq j 0)
  1018.     (foreach n the_list
  1019.       (if (/= value j)
  1020.         (setq temp_lisp_list (cons n temp_lisp_list))
  1021.       )
  1022.       (setq j (1+ j))
  1023.     )
  1024.     (setq temp_lisp_list (reverse temp_lisp_list))
  1025.   )
  1026.   ;;
  1027.   ;;  Get the fields of the highlighted item and place them in the edit area.
  1028.   ;;
  1029.   (defun do_edit()
  1030.     (setq edit_item (atoi (get_tile "filter_str_list")))  ;item in string list.
  1031.     (if (/= "" (nth edit_item filter_str_list))
  1032.       (progn
  1033.         (setq i -1)
  1034.         (setq edit_this -1)        ; corresponding item in lisp list.
  1035.         (while (< edit_this edit_item)  ; until they are equal
  1036.           (setq i (1+ i))
  1037.           (if (not (and (= -4 (car (nth i filter_lisp_list)))
  1038.                         (not (member (cdr (nth i filter_lisp_list))
  1039.                                     '("<AND" "AND>" "<OR"  "OR>"
  1040.                                       "<XOR" "XOR>" "<NOT" "NOT>")
  1041.                              )
  1042.                         )
  1043.                    )
  1044.               )
  1045.             (setq edit_this (1+ edit_this))
  1046.           )
  1047.         )
  1048.         (setq gc_name (nth edit_item filter_str_list))
  1049.         (setq a 1)
  1050.         (while (/= "\t" (substr gc_name a 1))
  1051.           (setq a (1+ a))
  1052.         )
  1053.         (setq str_name (substr gc_name 1 (1- a)))
  1054.         (setq j 1)(setq ws nil)
  1055.         (cond
  1056.           ((member (car (nth i filter_lisp_list)) '(-4 -3 1 2 3 6 8 38 39 40
  1057.                                                     41 43 44 45 50 51 62 66
  1058.                                                     70 71 10 11 12 13 14 15
  1059.                                                     16 210))
  1060.             (set_tile "filter_by"
  1061.                       (itoa (- (length filter_list)
  1062.                                (length (member str_name filter_list))
  1063.                             )
  1064.                       )
  1065.             )
  1066.           )
  1067.           ((member (car (nth i filter_lisp_list)) '(0))
  1068.             (cond
  1069.               ((= "ATTDEF" (cdr (nth i filter_lisp_list)))
  1070.                 (set_tile "filter_by"
  1071.                           (itoa (what_pos "Attribute" filter_list))
  1072.                 )
  1073.               )
  1074.               ((= "INSERT" (cdr (nth i filter_lisp_list)))
  1075.                 (set_tile "filter_by" (itoa (what_pos "Block" filter_list)))
  1076.               )
  1077.               (T
  1078.                 (set_tile "filter_by"
  1079.                           (itoa (- (length filter_list)
  1080.                                    (length
  1081.                                      (member
  1082.                                        (strcat
  1083.                                          (substr
  1084.                                            (cdr (nth i filter_lisp_list))
  1085.                                            1 1
  1086.                                          )
  1087.                                          (strcase
  1088.                                            (substr
  1089.                                              (cdr (nth i filter_lisp_list))
  1090.                                              2
  1091.                                            )
  1092.                                            T
  1093.                                          )
  1094.                                        )
  1095.                                        filter_list
  1096.                                      )
  1097.                                    )
  1098.                                 )
  1099.                           )
  1100.                     )
  1101.                 )
  1102.             )
  1103.           )
  1104.           (T (princ "│]⌐wíuby_filterívª│╗~ í╨ ║|»╩íu╕s╜Xív"))
  1105.         )
  1106.         (enable_disable str_name)
  1107.         (cond
  1108.           ((member (car (nth i filter_lisp_list)) '(10 11 12 13 14 15 16))
  1109.             (set_tile "x_value" (rtos (cadr (nth i filter_lisp_list))))
  1110.             (set_tile "y_value" (rtos (caddr (nth i filter_lisp_list))))
  1111.             (set_tile "z_value" (rtos (cadddr (nth i filter_lisp_list))))
  1112.             (setq ops_3 (cdr (nth (1- i) filter_lisp_list)))
  1113.             (setq j 1)
  1114.             (setq c1 nil) (setq c2 nil)
  1115.             (while (<= j (strlen ops_3))
  1116.               (cond
  1117.                 ((and (= "," (substr ops_3 j 1))
  1118.                       (= nil c1))
  1119.                   (setq c1 j)
  1120.                 )
  1121.                 ((and (= "," (substr ops_3 j 1))
  1122.                       (/= nil c1))
  1123.                   (setq c2 j)
  1124.                 )
  1125.               )
  1126.               (setq j (1+ j))
  1127.             )
  1128.             (set_tile "x_op"
  1129.                       (rtos (- (length ri_ops)
  1130.                                (length
  1131.                                  (member (substr ops_3 1 (- c1 1)) ri_ops))
  1132.                                )
  1133.                       )
  1134.             )
  1135.             (set_tile "y_op"
  1136.                       (rtos (- (length ri_ops)
  1137.                                (length
  1138.                                  (member
  1139.                                    (substr ops_3 (1+ c1) (1- (- c2 c1)))
  1140.                                    ri_ops
  1141.                                  )
  1142.                                )
  1143.                             )
  1144.                       )
  1145.             )
  1146.             (set_tile "z_op"
  1147.                       (rtos (- (length ri_ops)
  1148.                                (length (member (substr ops_3 (1+ c2)) ri_ops))
  1149.                             )
  1150.                       )
  1151.             )
  1152.           )
  1153.           ((member (car (nth i filter_lisp_list)) '(210))
  1154.             (set_tile "x_value" (rtos (cadr (nth i filter_lisp_list))))
  1155.             (set_tile "y_value" (rtos (caddr (nth i filter_lisp_list))))
  1156.             (set_tile "z_value" (rtos (cadddr (nth i filter_lisp_list))))
  1157.             (set_tile "x_op"
  1158.                       (rtos (- (length ri_ops)
  1159.                                (length
  1160.                                  (member
  1161.                                    (cdr (nth (- i 1) filter_lisp_list))
  1162.                                    ri_ops
  1163.                                  )
  1164.                                )
  1165.                             )
  1166.                       )
  1167.             )
  1168.           )
  1169.           ((member (car (nth i filter_lisp_list)) '(38 39 40 41 44 45 50 51))
  1170.             (set_tile "x_value" (rtos (cdr (nth i filter_lisp_list))))
  1171.             (set_tile "x_op"
  1172.                       (rtos (- (length ri_ops)
  1173.                                (length
  1174.                                  (member
  1175.                                    (cdr (nth (- i 1) filter_lisp_list))
  1176.                                    ri_ops
  1177.                                  )
  1178.                                )
  1179.                             )
  1180.                       )
  1181.             )
  1182.           )
  1183.           ((member (car (nth i filter_lisp_list)) '(66 70 71))      ; integers
  1184.             (set_tile "x_value" (itoa (cdr (nth i filter_lisp_list))))
  1185.             (set_tile "x_op"
  1186.                       (rtos (- (length ri_ops)
  1187.                                (length
  1188.                                  (member
  1189.                                    (cdr (nth (- i 1) filter_lisp_list))
  1190.                                    ri_ops
  1191.                                  )
  1192.                                )
  1193.                             )
  1194.                       )
  1195.             )
  1196.           )
  1197.           ((member (car (nth i filter_lisp_list)) '(62))      ;  Color
  1198.             (set_tile "x_value" (itoa (cdr (nth i filter_lisp_list))))
  1199.             (set_tile "x_op"
  1200.                       (rtos (- (length ri_ops)
  1201.                                (length
  1202.                                  (member
  1203.                                    (cdr (nth (- i 1) filter_lisp_list))
  1204.                                    ri_ops
  1205.                                  )
  1206.                                )
  1207.                             )
  1208.                       )
  1209.             )
  1210.           )
  1211.           ((member (car (nth i filter_lisp_list)) '(2 3 5))      ; strings
  1212.             (set_tile "x_value" (cdr (nth i filter_lisp_list)))
  1213.           )
  1214.           ((member (car (nth i filter_lisp_list)) '(6 8))      ;  table strings
  1215.             (set_tile "x_value" (cdr (nth i filter_lisp_list)))
  1216.           )
  1217.           ((member (car (nth i filter_lisp_list)) '(-3))      ; xdata
  1218.             (set_tile "x_value" (caadr (nth i filter_lisp_list)))
  1219.           )
  1220.           ((member (car (nth i filter_lisp_list)) '(0))     ; 0 code is special
  1221.           )
  1222.           ((member (car (nth i filter_lisp_list)) '(-4))      ; -4 code is special
  1223.           )
  1224.         )
  1225.       )
  1226.     )
  1227.   )
  1228.   ;;
  1229.   ;; Clears the list.
  1230.   ;;
  1231.   (defun clear_list()
  1232.     (setq filter_lisp_list '())
  1233.     (setq filter_str_list '(""))
  1234.     (setq str_pos 0)
  1235.     (setq ai_lisp|*unnamed filter_lisp_list)
  1236.     (setq ai_str|*unnamed filter_str_list)
  1237.     (set_tile "named_lists" "0")
  1238.     (start_list "filter_str_list")
  1239.     (mapcar 'add_list filter_str_list)
  1240.     (end_list)
  1241.   )
  1242.   ;;
  1243.   ;;  Hide the dialogue, allow user selection of an entity, get the relevant
  1244.   ;;  information, translate to English, add both Lisp and English to relevant
  1245.   ;;  lists at current cursor position.
  1246.   ;;
  1247.   (defun get_entity()
  1248.     (setq entity_lisp '())
  1249.     (if (setq entity_ename (entsel))
  1250.       (progn
  1251.         (setq entity_lisp_init (cdr (entget (car entity_ename) (list "*"))))
  1252.         (setq entity_type (cdar entity_lisp_init))
  1253.         (cond
  1254.           ((= entity_type "ARC")      (do_arc))
  1255.           ((= entity_type "CIRCLE")   (do_circle))
  1256.           ((= entity_type "INSERT")   (do_block))
  1257.           ((= entity_type "LINE")     (do_line))
  1258.           ((= entity_type "POINT")    (do_point))
  1259.           ((= entity_type "POLYLINE") (do_polyline))
  1260.           ((= entity_type "SHAPE")    (do_shape))
  1261.           ((= entity_type "SOLID")    (do_solid))
  1262.           ((= entity_type "TEXT")     (do_text))
  1263.           ((= entity_type "ATTDEF")   (do_attdef))
  1264.           ((= entity_type "TRACE")    (do_trace))
  1265.           ((= entity_type "3DFACE")   (do_3dface))
  1266.           ((= entity_type "VIEWPORT") (do_viewport))
  1267.           ((= entity_type "DIMENSION") (do_dimension))
  1268.           (T (temp))
  1269.         )
  1270.         (update (lts entity_lisp 0) entity_lisp_list)
  1271.       )
  1272.     )
  1273.   )
  1274.   ;;
  1275.   ;;  Arc
  1276.   ;;
  1277.   (defun do_arc()
  1278.     (foreach n entity_lisp_init
  1279.       (cond
  1280.         ((= 0   (car n)) (group_0  "Arc"))
  1281.         ((= 8   (car n)) (group_8  "Layer"))
  1282.         ((= 6   (car n)) (group_8  "Linetype"))
  1283.         ((= 38  (car n)) (group_40 "Elevation"))
  1284.         ((= 39  (car n)) (group_40 "Thickness"))
  1285.         ((= 62  (car n)) (group_62 "Color"))
  1286.         ((= 10  (car n)) (group_10 "Arc Center"))
  1287.         ((= 40  (car n)) (group_40 "Arc Radius"))
  1288.         ((= 210 (car n)) (group_210))
  1289.         ((= -3  (car n)) (group_-3))
  1290.         (t)
  1291.       )
  1292.     )
  1293.   )
  1294.   ;;
  1295.   ;;  Attribute Definition.
  1296.   ;;
  1297.   (defun do_attdef()
  1298.     (foreach n entity_lisp_init
  1299.       (cond
  1300.         ((= 0   (car n)) (group_0  "Attribute"))
  1301.         ((= 8   (car n)) (group_8  "Layer"))
  1302.         ((= 6   (car n)) (group_8  "Linetype"))
  1303.         ((= 38  (car n)) (group_40 "Elevation"))
  1304.         ((= 39  (car n)) (group_40 "Thickness"))
  1305.         ((= 62  (car n)) (group_62 "Color"))
  1306.         ((= 2   (car n)) (group_8  "Attribute Tag"))
  1307.         ((= 10  (car n)) (group_10 "Attribute Position"))
  1308.         ((= 210 (car n)) (group_210))
  1309.         ((= -3  (car n)) (group_-3))
  1310.       )
  1311.     )
  1312.   )
  1313.   ;;
  1314.   ;;  Insert Entity aka block
  1315.   ;;
  1316.   (defun do_block()
  1317.     (foreach n entity_lisp_init
  1318.       (cond
  1319.         ((= 0   (car n)) (group_0  "Block"))
  1320.         ((= 8   (car n)) (group_8  "Layer"))
  1321.         ((= 6   (car n)) (group_8  "Linetype"))
  1322.         ((= 38  (car n)) (group_40 "Elevation"))
  1323.         ((= 39  (car n)) (group_40 "Thickness"))
  1324.         ((= 62  (car n)) (group_62 "Color"))
  1325.         ((= 2   (car n)) (group_8  "Block Name"))
  1326.         ((= 10  (car n)) (group_10 "Block Position"))
  1327.         ((= 50  (car n)) (group_40 "Block Rotation"))
  1328.         ((= 210 (car n)) (group_210))
  1329.         ((= -3  (car n)) (group_-3))
  1330.       )
  1331.     )
  1332.   )
  1333.   ;;
  1334.   ;; Circle
  1335.   ;;
  1336.   (defun do_circle()
  1337.     (foreach n entity_lisp_init
  1338.       (cond
  1339.         ((= 0   (car n)) (group_0  "Circle"))
  1340.         ((= 8   (car n)) (group_8  "Layer"))
  1341.         ((= 6   (car n)) (group_8  "Linetype"))
  1342.         ((= 38  (car n)) (group_40 "Elevation"))
  1343.         ((= 39  (car n)) (group_40 "Thickness"))
  1344.         ((= 62  (car n)) (group_62 "Color"))
  1345.         ((= 10  (car n)) (group_10 "Circle Center"))
  1346.         ((= 40  (car n)) (group_40 "Circle Radius"))
  1347.         ((= 210 (car n)) (group_210))
  1348.         ((= -3  (car n)) (group_-3))
  1349.       )
  1350.     )
  1351.   )
  1352.   ;;
  1353.   ;;  Dimension
  1354.   ;;
  1355.   (defun do_dimension()
  1356.     (foreach n entity_lisp_init
  1357.       (cond
  1358.         ((= 0   (car n)) (group_0  "Dimension"))
  1359.         ((= 8   (car n)) (group_8  "Layer"))
  1360.         ((= 6   (car n)) (group_8  "Linetype"))
  1361.         ((= 38  (car n)) (group_40 "Elevation"))
  1362.         ((= 39  (car n)) (group_40 "Thickness"))
  1363.         ((= 62  (car n)) (group_62 "Color"))
  1364.         ((= 3   (car n)) (group_8   "Dimension Style"))
  1365.         ((= 210 (car n)) (group_210))
  1366.         ((= -3  (car n)) (group_-3))
  1367.       )
  1368.     )
  1369.   )
  1370.   ;;
  1371.   ;;  Line
  1372.   ;;
  1373.   (defun do_line()
  1374.     (foreach n entity_lisp_init
  1375.       (cond
  1376.         ((= 0   (car n)) (group_0  "Line"))
  1377.         ((= 8   (car n)) (group_8  "Layer"))
  1378.         ((= 6   (car n)) (group_8  "Linetype"))
  1379.         ((= 38  (car n)) (group_40 "Elevation"))
  1380.         ((= 39  (car n)) (group_40 "Thickness"))
  1381.         ((= 62  (car n)) (group_62 "Color"))
  1382.         ((= 10  (car n)) (group_10 "Line Start"))
  1383.         ((= 11  (car n)) (group_10 "Line End"))
  1384.         ((= 210 (car n)) (group_210))
  1385.         ((= -3  (car n)) (group_-3))
  1386.       )
  1387.     )
  1388.   )
  1389.   ;;
  1390.   ;;  Point
  1391.   ;;
  1392.   (defun do_point()
  1393.     (foreach n entity_lisp_init
  1394.       (cond
  1395.         ((= 0   (car n)) (group_0  "Point"))
  1396.         ((= 8   (car n)) (group_8  "Layer"))
  1397.         ((= 6   (car n)) (group_8  "Linetype"))
  1398.         ((= 38  (car n)) (group_40 "Elevation"))
  1399.         ((= 39  (car n)) (group_40 "Thickness"))
  1400.         ((= 62  (car n)) (group_62 "Color"))
  1401.         ((= 10  (car n)) (group_10 "Point Position"))
  1402.         ((= 210 (car n)) (group_210))
  1403.         ((= -3  (car n)) (group_-3))
  1404.       )
  1405.     )
  1406.   )
  1407.   ;;
  1408.   ;;  Polyline
  1409.   ;;
  1410.   (defun do_polyline()
  1411.     (foreach n entity_lisp_init
  1412.       (cond
  1413.         ((= 0   (car n)) (group_0  "Polyline"))
  1414.         ((= 8   (car n)) (group_8  "Layer"))
  1415.         ((= 6   (car n)) (group_8  "Linetype"))
  1416.         ((= 38  (car n)) (group_40 "Elevation"))
  1417.         ((= 39  (car n)) (group_40 "Thickness"))
  1418.         ((= 62  (car n)) (group_62 "Color"))
  1419.         ((= 210 (car n)) (group_210))
  1420.         ((= -3  (car n)) (group_-3))
  1421.       )
  1422.     )
  1423.   )
  1424.   ;;
  1425.   ;;  Shape
  1426.   ;;
  1427.   (defun do_shape()
  1428.     (foreach n entity_lisp_init
  1429.       (cond
  1430.         ((= 0   (car n)) (group_0  "Shape"))
  1431.         ((= 8   (car n)) (group_8  "Layer"))
  1432.         ((= 6   (car n)) (group_8  "Linetype"))
  1433.         ((= 38  (car n)) (group_40 "Elevation"))
  1434.         ((= 39  (car n)) (group_40 "Thickness"))
  1435.         ((= 62  (car n)) (group_62 "Color"))
  1436.         ((= 10  (car n)) (group_10 "Shape Position"))
  1437.         ((= 2   (car n)) (group_8  "Shape Name"))
  1438.         ((= 210 (car n)) (group_210))
  1439.         ((= -3  (car n)) (group_-3))
  1440.       )
  1441.     )
  1442.   )
  1443.   ;;
  1444.   ;;  Solid
  1445.   ;;
  1446.   (defun do_solid()
  1447.     (foreach n entity_lisp_init
  1448.       (cond
  1449.         ((= 0   (car n)) (group_0  "Solid"))
  1450.         ((= 8   (car n)) (group_8  "Layer"))
  1451.         ((= 6   (car n)) (group_8  "Linetype"))
  1452.         ((= 38  (car n)) (group_40 "Elevation"))
  1453.         ((= 39  (car n)) (group_40 "Thickness"))
  1454.         ((= 62  (car n)) (group_62 "Color"))
  1455.         ((= 10  (car n)) (group_10 "Solid Point 1"))
  1456.         ((= 11  (car n)) (group_10 "Solid Point 2"))
  1457.         ((= 12  (car n)) (group_10 "Solid Point 3"))
  1458.         ((= 13  (car n)) (group_10 "Solid Point 4"))
  1459.         ((= 210 (car n)) (group_210))
  1460.         ((= -3  (car n)) (group_-3))
  1461.       )
  1462.     )
  1463.   )
  1464.   ;;
  1465.   ;;  Text
  1466.   ;;
  1467.   (defun do_text()
  1468.     (foreach n entity_lisp_init
  1469.       (cond
  1470.         ((= 0   (car n)) (group_0  "Text"))
  1471.         ((= 8   (car n)) (group_8  "Layer"))
  1472.         ((= 6   (car n)) (group_8  "Linetype"))
  1473.         ((= 38  (car n)) (group_40 "Elevation"))
  1474.         ((= 39  (car n)) (group_40 "Thickness"))
  1475.         ((= 62  (car n)) (group_62 "Color"))
  1476.         ((= 10  (car n)) (group_10 "Text Position"))
  1477.         ((= 1   (car n)) (group_8  "Text Value"))
  1478.         ((= 7   (car n)) (group_8  "Text Style Name"))
  1479.         ((= 40  (car n)) (group_40 "Text Height"))
  1480.         ((= 50  (car n)) (group_40 "Text Rotation"))
  1481.         ((= 210 (car n)) (group_210))
  1482.         ((= -3  (car n)) (group_-3))
  1483.       )
  1484.     )
  1485.   )
  1486.   ;;
  1487.   ;;   Trace
  1488.   ;;
  1489.   (defun do_trace()
  1490.     (foreach n entity_lisp_init
  1491.       (cond
  1492.         ((= 0   (car n)) (group_0  "Trace"))
  1493.         ((= 8   (car n)) (group_8  "Layer"))
  1494.         ((= 6   (car n)) (group_8  "Linetype"))
  1495.         ((= 38  (car n)) (group_40 "Elevation"))
  1496.         ((= 39  (car n)) (group_40 "Thickness"))
  1497.         ((= 62  (car n)) (group_62 "Color"))
  1498.         ((= 10  (car n)) (group_10 "Trace Point 1"))
  1499.         ((= 11  (car n)) (group_10 "Trace Point 2"))
  1500.         ((= 12  (car n)) (group_10 "Trace Point 3"))
  1501.         ((= 13  (car n)) (group_10 "Trace Point 4"))
  1502.         ((= 210 (car n)) (group_210))
  1503.         ((= -3  (car n)) (group_-3))
  1504.       )
  1505.     )
  1506.   )
  1507.   ;;
  1508.   ;;   3Dface
  1509.   ;;
  1510.   (defun do_3dface()
  1511.     (foreach n entity_lisp_init
  1512.       (cond
  1513.         ((= 0   (car n)) (group_0  "3dface"))
  1514.         ((= 8   (car n)) (group_8  "Layer"))
  1515.         ((= 6   (car n)) (group_8  "Linetype"))
  1516.         ((= 38  (car n)) (group_40 "Elevation"))
  1517.         ((= 39  (car n)) (group_40 "Thickness"))
  1518.         ((= 62  (car n)) (group_62 "Color"))
  1519.         ((= 10  (car n)) (group_10 "3dface Point 1"))
  1520.         ((= 11  (car n)) (group_10 "3dface Point 2"))
  1521.         ((= 12  (car n)) (group_10 "3dface Point 3"))
  1522.         ((= 13  (car n)) (group_10 "3dface Point 4"))
  1523.         ((= 210 (car n)) (group_210))
  1524.         ((= -3  (car n)) (group_-3))
  1525.       )
  1526.     )
  1527.   )
  1528.   ;;
  1529.   ;;  Viewport
  1530.   ;;
  1531.   (defun do_viewport()
  1532.     (foreach n entity_lisp_init
  1533.       (cond
  1534.         ((= 0   (car n)) (group_0  "Viewport"))
  1535.         ((= 8   (car n)) (group_8  "Layer"))
  1536.         ((= 6   (car n)) (group_8  "Linetype"))
  1537.         ((= 38  (car n)) (group_40 "Elevation"))
  1538.         ((= 39  (car n)) (group_40 "Thickness"))
  1539.         ((= 62  (car n)) (group_62 "Color"))
  1540.         ((= 10  (car n)) (group_10 "Viewport Center"))
  1541.         ((= 210 (car n)) (group_210))
  1542.         ((= -3  (car n)) (group_-3))
  1543.       )
  1544.     )
  1545.   )
  1546.   ;;
  1547.   ;;   Group code 0
  1548.   ;;
  1549.   (defun group_0(label)
  1550.     (setq entity_lisp (cons (list "Entity \t\t=\t" label) entity_lisp))
  1551.     (setq entity_lisp_list (list n))
  1552.   )
  1553.   ;;
  1554.   ;;   Strings
  1555.   ;;
  1556.   (defun group_8(label)
  1557.     (setq entity_lisp (cons (list label "\t\t=\t" (cdr n)) entity_lisp))
  1558.     (setq entity_lisp_list (reverse (cons n (reverse entity_lisp_list))))
  1559.   )
  1560.   ;;
  1561.   ;;   Coordinate
  1562.   ;;
  1563.   (defun group_10(label)
  1564.     (if (not (assoc 6 entity_lisp_list))
  1565.       (progn
  1566.         (setq entity_lisp
  1567.               (cons (list "Linetype\t\t=\t" "BYLAYER") entity_lisp)
  1568.         )
  1569.         (setq entity_lisp_list
  1570.               (reverse (cons (cons 6 "BYLAYER") (reverse entity_lisp_list)))
  1571.         )
  1572.       )
  1573.     )
  1574.     (if (not (assoc 62 entity_lisp_list))
  1575.       (progn
  1576.         (setq entity_lisp (cons (list "Color\t\t=\t" "BYLAYER") entity_lisp))
  1577.         (setq entity_lisp_list
  1578.               (reverse (cons
  1579.                          (cons 62 256)
  1580.                          (cons (cons -4 "=") (reverse entity_lisp_list))
  1581.                        )
  1582.                )
  1583.         )
  1584.       )
  1585.     )
  1586.     (setq entity_lisp (cons (list label
  1587.                                    "\tX\t=\t" (rtos (cadr n))
  1588.                                    "\tY\t=\t" (rtos (caddr n))
  1589.                                    "\tZ\t=\t" (rtos (cadddr n))
  1590.                              )
  1591.                              entity_lisp))
  1592.     (setq entity_lisp_list
  1593.           (reverse
  1594.             (cons n (cons (cons -4 "=,=,=") (reverse entity_lisp_list)))
  1595.           )
  1596.     )
  1597.   )
  1598.   ;;
  1599.   ;;   Reals
  1600.   ;;
  1601.   (defun group_40(label)
  1602.     (setq entity_lisp (cons (list label "\t\t=\t" (rtos (cdr n))) entity_lisp))
  1603.     (setq entity_lisp_list
  1604.           (reverse (cons n (cons (cons -4 "=") (reverse entity_lisp_list))))
  1605.     )
  1606.   )
  1607.   ;;
  1608.   ;;   Color
  1609.   ;;
  1610.   (defun group_62(label / str)
  1611.     (setq str (cdr n))
  1612.     (cond
  1613.       ((= 0 str)   (setq str "0 - By Block"))
  1614.       ((= 1 str)   (setq str "1 - Red"))
  1615.       ((= 2 str)   (setq str "2 - Yellow"))
  1616.       ((= 3 str)   (setq str "3 - Green"))
  1617.       ((= 4 str)   (setq str "4 - Cyan"))
  1618.       ((= 5 str)   (setq str "5 - Blue"))
  1619.       ((= 6 str)   (setq str "6 - Magenta"))
  1620.       ((= 7 str)   (setq str "7 - White"))
  1621.       ((= 256 str) (setq str "256 - By Layer"))
  1622.       (t (setq str (itoa str)))
  1623.     )
  1624.     (setq entity_lisp (cons (list label "\t\t=\t" str) entity_lisp))
  1625.     (setq entity_lisp_list
  1626.           (reverse (cons n (cons (cons -4 "=") (reverse entity_lisp_list))))
  1627.     )
  1628.   )
  1629.   ;;
  1630.   ;;   Normal Vector
  1631.   ;;
  1632.   (defun group_210()
  1633.     (if (not (assoc 6 entity_lisp_list))
  1634.       (progn
  1635.         (setq entity_lisp
  1636.               (cons (list "Linetype\t\t=\t" "BYLAYER") entity_lisp)
  1637.         )
  1638.         (setq entity_lisp_list
  1639.               (reverse (cons (cons 6 "BYLAYER") (reverse entity_lisp_list)))
  1640.         )
  1641.       )
  1642.     )
  1643.     (if (not (assoc 62 entity_lisp_list))
  1644.       (progn
  1645.         (setq entity_lisp (cons (list "Color\t\t=\t" "BYLAYER") entity_lisp))
  1646.         (setq entity_lisp_list (reverse (cons (cons 62 256) (cons (cons -4 "=") (reverse entity_lisp_list)))))
  1647.       )
  1648.     )
  1649.     (setq entity_lisp (cons (list "Normal Vector"
  1650.                                    "\tX\t=\t" (rtos (cadr n))
  1651.                                    "\tY\t=\t" (rtos (caddr n))
  1652.                                    "\tZ\t=\t" (rtos (cadddr n))
  1653.                              )
  1654.                              entity_lisp))
  1655.     (setq entity_lisp_list
  1656.           (reverse (cons n (cons (cons -4 "=") (reverse entity_lisp_list))))
  1657.     )
  1658.   )
  1659.   ;;
  1660.   ;;    Xdata ID
  1661.   ;;
  1662.   (defun group_-3()
  1663.     (setq appid_str "")
  1664.     (if (< 1 (length n))
  1665.       (progn
  1666.         (foreach n1 (cdr n)
  1667.           (setq appid_str (strcat (car n1) "," appid_str))
  1668.         )
  1669.         (setq appid_str (substr appid_str 1 (1- (strlen appid_str))))
  1670.         (setq entity_lisp (subst (list "Xdata ID \t\t=\t" appid_str)
  1671.                                  n
  1672.                                  entity_lisp
  1673.                           )
  1674.         )
  1675.         (setq entity_lisp_list
  1676.               (reverse
  1677.                 (cons (list -3 (list appid_str)) (reverse entity_lisp_list))
  1678.               )
  1679.         )
  1680.       )
  1681.     )
  1682.   )
  1683.   ;;
  1684.   ;; Changes list of lists to list of strings, if bit_flag = 1 return parens.
  1685.   ;;
  1686.   (defun lts (the_list bit_flag / n n1 dp1 dp2)
  1687.     (setq list_str '())       ; for display in list box.
  1688.     (foreach n the_list
  1689.       (cond
  1690.         ((= -3 (car n))
  1691.           (setq str (strcat "( -3" "(" "\"" (caadr n) "\"" "))" ))
  1692.         )
  1693.         ((/= (type (cdr n)) 'LIST)     ; is it a dotted pair or a list.
  1694.           (setq str "")
  1695.           (setq dp1 (what_is_it (car n)))  ; broken out for clarity.
  1696.           (setq dp2 (what_is_it (cdr n)))
  1697.           ; cdrs are strings except for color, elevation, and thickness
  1698.           (if (member (car n) '(38 39 40 41 42 43 50 51 62))
  1699.             (setq str (strcat "(" dp1 " . " dp2 ")"))
  1700.             (setq str (strcat "(" dp1 " . " "\"" dp2 "\""  ")"))
  1701.           )
  1702.         )
  1703.         (T
  1704.           (setq str "")
  1705.           (cond
  1706.             ((= 1 bit_flag)
  1707.               (foreach n1 n
  1708.                 (setq str (strcat str (what_is_it n1) " "))
  1709.               )
  1710.             )
  1711.             ((= 0 bit_flag)
  1712.               (foreach n1 n
  1713.                 (setq str (strcat str (what_is_it n1)))
  1714.               )
  1715.             )
  1716.           )
  1717.           ; get rid of last white space
  1718.           (if (= 1 bit_flag)
  1719.             (setq str (strcat "(" (substr str 1 (- (strlen str) 1)) ")" ))
  1720.           )
  1721.         )
  1722.       )
  1723.       (setq list_str (cons str list_str))
  1724.     )
  1725.   )
  1726.   ;;
  1727.   ;;  What type is it ??
  1728.   ;;
  1729.   (defun what_is_it (huh / hmmm)
  1730.     (cond
  1731.       ((= (type huh) 'INT)  (setq hmmm (itoa huh)))
  1732.       ((= (type huh) 'REAL) (setq hmmm (rtos huh (getvar "lunits") 16)))
  1733.       ((= (type huh) 'STR)  (setq hmmm huh ))
  1734.     )
  1735.     hmmm
  1736.   )
  1737.   ;;
  1738.   ;; Check Lisp list for errors.
  1739.   ;;
  1740.   (defun lisp_error(/ after_errno temp_ss)
  1741.     (setq temp_ss (ssget "X" filter_lisp_list))
  1742.     (setq after_errno (getvar "errno"))
  1743.     (cond
  1744.       ((= 56 after_errno)
  1745.         (set_tile "error" "íu┬o┬^ªC╢╡ív╡L«─ í╨ ╣Lª¡╡▓º⌠íC")
  1746.       )
  1747.       ((= 57 after_errno)
  1748.         (set_tile "┐∙╗~" "íu┬o┬^ªC╢╡ív╡L«─ í╨ ║|»╩íuñ±╕╒╣B║ΓñlívíC")
  1749.       )
  1750.        ((= 58 after_errno)
  1751.         (set_tile "error" "íu┬o┬^ªC╢╡ív╡L«─ í╨íuop_code ªrªΩív╡L«─íC")
  1752.       )
  1753.       ((= 59 after_errno)
  1754.         (set_tile "error" "íu┬o┬^ªC╢╡ív╡L«─ í╨ ¬┼¡zÑyí■▒_▓╒ª│╗~íC")
  1755.       )
  1756.       ((= 60 after_errno)
  1757.         (set_tile "error" "íu┬o┬^ªC╢╡ív╡L«─ í╨íu╢}⌐l/╡▓º⌠ív¡zÑyñú░t▓┼íC")
  1758.       )
  1759.       ((= 61 after_errno)
  1760.         (set_tile "error"
  1761.                   "íu┬o┬^ªC╢╡ív╡L«─ í╨íuXOR/NOTív╣B║Γñlª│┐∙╗~╝╞¡╚íC"
  1762.         )
  1763.       )
  1764.       ((= 62 after_errno)
  1765.         (set_tile "error" "íu┬o┬^ªC╢╡ív╡L«─ í╨ ╢WÑXíu▒_▓╒ívñW¡¡íC")
  1766.       )
  1767.       ((= 63 after_errno)
  1768.         (set_tile "error" "íu┬o┬^ªC╢╡ív╡L«─ í╨íu╕s╜Xív╡L«─íC")
  1769.       )
  1770.       ((= 64 after_errno)
  1771.         (set_tile "error" "íu┬o┬^ªC╢╡ív╡L«─ í╨íuªrªΩñ±╕╒ív╡L«─íC")
  1772.       )
  1773.       ((= 65 after_errno)
  1774.         (set_tile "error" "íu┬o┬^ªC╢╡ív╡L«─ í╨íuªV╢qñ±╕╒ív╡L«─íC")
  1775.       )
  1776.       ((= 66 after_errno)
  1777.         (set_tile "error" "íu┬o┬^ªC╢╡ív╡L«─ í╨íu╣Ω╝╞ñ±╕╒ív╡L«─íC")
  1778.       )
  1779.       ((= 67 after_errno)
  1780.         (set_tile "error" "íu┬o┬^ªC╢╡ív╡L«─ í╨íu╛π╝╞ñ±╕╒ív╡L«─íC")
  1781.       )
  1782.       (t nil)
  1783.     )
  1784.   )
  1785.   ;;
  1786.   ;; Puts up dialogue for table selection, returns a list of strings on OK and
  1787.   ;; nil on Cancel.
  1788.   ;;
  1789.   (defun single_table (table_name title / pat what_next selection_list)
  1790.     (if (not (new_dialog "single_table" dcl_id)) (exit))
  1791.     (setq table_list (ai_table table_name 8)) ; List items in specified table.
  1792.     (setq pat "*")                ; Set pattern to all items initially.
  1793.     (set_tile "pattern" pat)        ; Set the pattern to *.
  1794.     (set_tile "title" title)  ; Set the dialogue title to whatever.
  1795.     (pat_match pat "table_match")
  1796.  
  1797.     ;; Define what happens when each button is pressed.
  1798.     (action_tile "pattern"
  1799.                  "(pat_match (setq pat (strcase $value)) \"table_match\")")
  1800.  
  1801.     (action_tile "table_match" "(make_list)")
  1802.     ;; return the selection_list on OK.
  1803.     (setq what_next (start_dialog))
  1804.     (if (= 1 what_next) selection_list nil)  ; return list on OK
  1805.   )
  1806.   ;;
  1807.   ;; Add to Selection List.
  1808.   ;;
  1809.   (defun make_list (/ item_index string temp_list a)
  1810.     (setq selection_list '())     ; initialise list
  1811.     (setq string (get_tile "table_match"))
  1812.     (setq a 0)
  1813.     (while (/= (read string) nil)
  1814.       (setq item_index (itoa (read string)))
  1815.       (setq string (substr string (+ 2 (strlen item_index))))
  1816.       (setq selection_list
  1817.              (cons (nth (atoi item_index) table_match) selection_list))
  1818.       (setq a (1+ a))
  1819.     )
  1820.     (setq selection_list (reverse selection_list))
  1821.     (set_tile "error" (strcat "┐∩ñJ " (itoa a) " ╢╡íu" table_name "ívíC"))
  1822.   )
  1823.   ;;
  1824.   ;; This function displays the table list based on the pattern.
  1825.   ;;
  1826.   (defun pat_match (pat which_box / which_list a)
  1827.     (setq which_list '())
  1828.     (setq a 0)
  1829.     (foreach n table_list
  1830.       (if (wcmatch n pat)
  1831.         (progn
  1832.           (setq which_list (cons n which_list))
  1833.         )
  1834.       )
  1835.       (setq a (1+ a))
  1836.     )
  1837.     ;; Alphabetize the matched list.
  1838.     (if (and which_list
  1839.              (< (length which_list) (getvar "maxsort"))
  1840.         )
  1841.       (setq which_list (acad_strlsort which_list))
  1842.     )
  1843.     (start_list which_box)
  1844.     (mapcar 'add_list which_list)
  1845.     (end_list)
  1846.     (set (read (eval which_box)) which_list)
  1847.   )
  1848.   ;;
  1849.   ;; If an error occurs on reading filter.nfl, it is due to a syntax error
  1850.   ;; introduced by someone editing the file.
  1851.   ;;
  1852.   (defun load_error (s)
  1853.     (princ "\n¿πªW¬║íu┬o┬^ªC│µ└╔«╫ívññª│╗y¬k┐∙╗~; ºR░ú filter.nflíC")
  1854.     (if old_error (setq *error* old_error))   ; Restore old *error* handler
  1855.     (princ)
  1856.   )
  1857.  
  1858.   ;;
  1859.   ;; Put up the dialogue.
  1860.   ;;
  1861.   (defun filter_main()
  1862.  
  1863.     ;; Set up error function.
  1864.     (setq old_cmd (getvar "cmdecho")    ; save current setting of cmdecho
  1865.           old_error  *error*            ; save current error function
  1866.           *error* load_error              ; new error function
  1867.     )
  1868.  
  1869.     (setvar "cmdecho" 0)
  1870.  
  1871.     (setq str_pos           nil
  1872.           what_next         3
  1873.           filter_str_list   '("")
  1874.           filter_lisp_list  '()
  1875.           all_lisp_list     '("*unnamed")
  1876.     )
  1877.     (load_log)     ; if there is a file containing named filter lists, load it.
  1878.  
  1879.     (setq *error* ai_error)  ; After loading reset error to normal error.
  1880.  
  1881.     (init_lists)   ; initialise the big lists.
  1882.     (while (< 1 what_next)             ; loop for hiding dialogue.
  1883.       (if (not (new_dialog "filter" dcl_id)) (exit))
  1884.       (set_tile "x_value" "0.0000")   ; some default values
  1885.       (set_tile "y_value" "0.0000")
  1886.       (set_tile "z_value" "0.0000")
  1887.       (mode_tile "x_text" 1)(mode_tile "y_text" 1)(mode_tile "z_text" 1)
  1888.       (mode_tile "x_op" 1) (mode_tile "x_value" 1)
  1889.       (mode_tile "y_op" 1) (mode_tile "y_value" 1)
  1890.       (mode_tile "z_op" 1) (mode_tile "z_value" 1)
  1891.       (mode_tile "select" 1)
  1892.  
  1893.       (start_list "filter_by")           ; the list of possible filters
  1894.       (mapcar 'add_list filter_list)
  1895.       (end_list)
  1896.  
  1897.       (start_list "filter_str_list")     ; the list of chosen filters
  1898.       (mapcar 'add_list filter_str_list)
  1899.       (end_list)
  1900.  
  1901.       (start_list "named_lists")         ; the list of named filter lists
  1902.       (mapcar 'add_list all_lisp_list)
  1903.       (end_list)
  1904.  
  1905.       (start_list "x_op")                ; the list of X coordinate filters
  1906.       (mapcar 'add_list ri_ops)
  1907.       (end_list)
  1908.  
  1909.       (start_list "y_op")
  1910.       (mapcar 'add_list ri_ops)          ; the list of Y coordinate filters
  1911.       (end_list)
  1912.  
  1913.       (start_list "z_op")                ; the list of Z coordinate filters
  1914.       (mapcar 'add_list ri_ops)
  1915.       (end_list)
  1916.  
  1917.       (if (not str_pos) (setq str_pos 0)) ; position within string list
  1918.  
  1919.       (if (not pick)                   ; current selection in possible filters
  1920.         (progn
  1921.           (setq pick "Arc")
  1922.           (set_tile "filter_by" "0")
  1923.         )
  1924.         (progn
  1925.           (set_tile "filter_by" (itoa (what_pos pick filter_list)))
  1926.           (grey_filter)
  1927.         )
  1928.       )
  1929.       ;; Get the default named list from ai_defaults.
  1930.       (if (and (= 3 what_next)
  1931.                (setq last_name (cadr (assoc "filter" ai_defaults)))
  1932.           )
  1933.         (progn
  1934.           (if (not (member last_name all_lisp_list))  ; may no longer exist.
  1935.             (setq last_name "*unnamed")
  1936.           )
  1937.           (setq pick_list (what_pos last_name all_lisp_list))
  1938.           (set_tile "named_lists" (itoa pick_list))
  1939.           (setq filter_str_list (eval (read (strcat "ai_str|" last_name))))
  1940.           (setq filter_lisp_list (eval (read (strcat "ai_lisp|" last_name))))
  1941.           (start_list "filter_str_list")
  1942.           (mapcar 'add_list filter_str_list)
  1943.           (end_list)
  1944.         )
  1945.         (progn
  1946.           (setq pick_list 0)
  1947.           (set_tile "named_lists" "0")
  1948.           (setq last_name "*unnamed")
  1949.         )
  1950.       )
  1951.  
  1952.       (set_tile "filter_str_list" (itoa str_pos))
  1953.  
  1954.       (action_tile "filter_str_list" "(rs_err)(setq str_pos (atoi $value))")
  1955.       (action_tile "select_entity"   "(rs_err)(do_select_entity)")
  1956.       (action_tile "edit"            "(rs_err)(do_edit)")
  1957.       (action_tile "clear_list"      "(rs_err)(clear_list)")
  1958.       (action_tile "remove"          "(rs_err)(do_remove)")
  1959.       (action_tile "filter_by"       "(rs_err)(grey_filter)")
  1960.       (action_tile "select"          "(rs_err)(select)")
  1961.       (action_tile "add_to_list"     "(rs_err)(add_to_list)")
  1962.       (action_tile "substitute"      "(rs_err)(remove)(add_to_list)")
  1963.       (action_tile "apply"           "(if (not (lisp_error))(done_dialog 1))")
  1964.       (action_tile "save_as"         "(rs_err)(save_as)")
  1965.       (action_tile "named_lists"     "(rs_err)(named_lists)")
  1966.       (action_tile "delete_list"     "(rs_err)(delete_list)")
  1967.       (action_tile "help"            "(acad_helpdlg \"acad.hlp\" \"filter\")")
  1968.  
  1969.       (setq what_next (start_dialog))
  1970.       (if (= 2 what_next) (get_entity))
  1971.     )
  1972.     (if (= 1 what_next)
  1973.       (progn
  1974.         ;; Use this name as the default next time.
  1975.         (if (not list_name) (setq list_name "*unnamed"))
  1976.         (if (assoc "filter" ai_defaults)
  1977.           (setq ai_defaults (subst (list "filter" list_name)
  1978.                                    (assoc "filter" ai_defaults)
  1979.                                    ai_defaults
  1980.                             )
  1981.           )
  1982.           (setq ai_defaults (cons (list "filter" list_name) ai_defaults))
  1983.         )
  1984.         (princ "\n╣BÑ╬íu┬o┬^│B▓zív╢iªµ┐∩╛▄íC ")
  1985.         (setq ret_list (ssget filter_lisp_list))
  1986.         (princ "\n░hÑXíu┬o┬^┐∩╛▄ívíC  ")
  1987.       )
  1988.     )
  1989.     (foreach n all_lisp_list      ; set all named lists to nil
  1990.       (if (/= n "*unnamed")
  1991.         (progn
  1992.           (set (read (strcat "ai_str|" n)) nil)
  1993.           (set (read (strcat "ai_lisp|" n)) nil)
  1994.         )
  1995.       )
  1996.     )
  1997.     (setq *error* old_error)
  1998.     (setvar "cmdecho" old_cmd)
  1999.   )
  2000.  
  2001.   (cond
  2002.      (  (not (ai_transd)))                       ; transparent OK
  2003.      (  (not (ai_acadapp)))                      ; ACADAPP.EXP xloaded?
  2004.      (  (not (setq dcl_id (ai_dcl "filter"))))  ; is .DCL file loaded?
  2005.      (t (filter_main))                          ; proceed!
  2006.   )
  2007.  
  2008.   ;; Return the list is there is a command active, else exit quietly.
  2009.   (if (and (/= 0 (getvar "cmdactive"))
  2010.            (= 1 what_next)
  2011.       )
  2012.     ret_list
  2013.     (princ)
  2014.   )
  2015. )
  2016.  
  2017. ;;;----------------------------------------------------------------------------
  2018. (princ "  íuFILTERívñw╕ⁿñJíC  ")
  2019. (princ)
  2020.  
  2021.