home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p024 / 5.img / R11SUPP.EXE / SSX.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1990-07-30  |  8.2 KB  |  227 lines

  1. ;;;   ssx.lsp
  2. ;;;   Copyright (C) 1990 by Autodesk, Inc.
  3. ;;;  
  4. ;;;   Permission to use, copy, modify, and distribute this software and its
  5. ;;;   documentation for any purpose and without fee is hereby granted.  
  6. ;;;
  7. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 
  8. ;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 
  9. ;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
  10. ;;; 
  11. ;;;   Larry Knott                        Version 2.0    7/18/88  
  12. ;;;   Carl Bethea & Jan S. Yoder         Version 3.0
  13. ;;;   Enhancements to (ssx).
  14. ;;;   15 March 1990  
  15. ;;;
  16. ;;;--------------------------------------------------------------------------;
  17. ;;; DESCRIPTION
  18. ;;;                              SSX.LSP                                    
  19. ;;;                                                                          
  20. ;;;   "(SSX)" -  Easy SSGET filter routine.                                    
  21. ;;;                                                                            
  22. ;;;   Creates a selection set.  Either type "SSX" at the "Command:" prompt   
  23. ;;;   to create a "previous" selection set or type "(SSX)" in response to 
  24. ;;;   any "Select objects:" prompt.  You may use the functions "(A)" to add 
  25. ;;;   entities and "(R)" to remove entities from a selection set during 
  26. ;;;   object selection.  More than one filter criteria can be used at a 
  27. ;;;   time.         
  28. ;;;                                                                          
  29. ;;;   SSX returns a selection set either exactly like a selected
  30. ;;;   entity or, by adjusting the filter list, similar to it.
  31. ;;;
  32. ;;;   The initial prompt is this:
  33. ;;;   
  34. ;;;     Command: ssx
  35. ;;;     Select object/<None>: (RETURN)
  36. ;;;     >>Block name/Color/Entity/Flag/LAyer/LType/Pick/Style/Thickness/Vector: 
  37. ;;;   
  38. ;;;   Pressing RETURN at the initial prompt gives you a null selection 
  39. ;;;   mechanism just as (ssx) did in Release 10, but you may select an 
  40. ;;;   entity if you desire.  If you do so, then the list of valid types 
  41. ;;;   allowed by (ssget "x") are presented on the command line.
  42. ;;;   
  43. ;;;     Select object/<None>:  (a LINE selected)
  44. ;;;     Filter: ((0 . "LINE") (8 . "0") (39 . 2.0) (62 . 1) (210 0.0 0.0 1.0)) 
  45. ;;;     >>Block name/Color/Entity/Flag/LAyer/LType/Pick/Style/Thickness/Vector: 
  46. ;;;   
  47. ;;;   At this point any of these filters may be removed by selecting the 
  48. ;;;   option keyword, then pressing RETURN.
  49. ;;;   
  50. ;;;     >>Layer name to add/<RETURN to remove>: (RETURN)
  51. ;;;         
  52. ;;;     Filter: ((0 . "LINE") (39 . 2.0) (62 . 1) (210 0.0 0.0 1.0))
  53. ;;;     >>Block name/Color/Entity/Flag/LAyer/LType/Pick/Style/Thickness/Vector: 
  54. ;;;   
  55. ;;;   If an item exists in the filter list and you elect to add a new item, 
  56. ;;;   the old value is overwritten by the new value, as you can have only 
  57. ;;;   one of each type in a single (ssget "x") call.
  58. ;;;
  59. ;;;--------------------------------------------------------------------------;
  60. ;;;
  61. ;;; Find the dotted pairs that are valid filters for ssget
  62. ;;; in entity named "ent".
  63. ;;;
  64. ;;; ssx_fe == SSX_Find_Entity
  65. ;;;
  66. (defun ssx_fe (/ x data fltr ent)
  67.   (setq ent (car (entsel "\nSelect object/<None>: ")))
  68.   (if ent
  69.     (progn
  70.       (setq data (entget ent))
  71.       (foreach x '(0 2 6 7 8 39 62 66 210) ; do not include 38
  72.         (if (assoc x data)
  73.           (setq fltr 
  74.             (cons (assoc x data) fltr)
  75.           )
  76.         )
  77.       )    
  78.       (reverse fltr)
  79.     )
  80.   ) 
  81. )
  82. ;;;
  83. ;;; Remove "element" from "alist".
  84. ;;;
  85. ;;; ssx_re == SSX_Remove_Element
  86. ;;;
  87. (defun ssx_re (element alist)
  88.   (append
  89.     (reverse (cdr (member element (reverse alist))))
  90.     (cdr (member element alist))   
  91.   )
  92. )
  93. ;;;
  94. ;;; INTERNAL ERROR HANDLER 
  95. ;;;
  96. (defun ssx_er (s)                     ; If an error (such as CTRL-C) occurs
  97.                                       ; while this command is active...
  98.   (if (/= s "Function cancelled")
  99.     (princ (strcat "\nError: " s))
  100.   )
  101.   (if olderr (setq *error* olderr))   ; Restore old *error* handler
  102.   (princ)
  103. )
  104. ;;;   
  105. ;;; Get the filtered sel-set.
  106. ;;;
  107. ;;;
  108. (defun ssx (/ olderr)
  109.   (gc)                                ; close any sel-sets            
  110.   (setq olderr *error* 
  111.         *error* ssx_er 
  112.   )
  113.   (setq fltr (ssx_fe)) 
  114.   (ssx_gf fltr) 
  115. )
  116. ;;;
  117. ;;; Build the filter list up by picking, selecting an item to add,
  118. ;;; or remove an item from the list by selecting it and pressing RETURN.
  119. ;;;
  120. ;;; ssx_gf == SSX_Get_Filters
  121. ;;;
  122. (defun ssx_gf (f1 / t1 t2 t3 f1 f2)
  123.   (while 
  124.     (progn
  125.       (cond (f1 (prompt "\nFilter: ") (prin1 f1)))
  126.       (initget 
  127.         "Block Color Entity Flag LAyer LType Pick Style Thickness Vector")
  128.       (setq t1 (getkword (strcat
  129.         "\n>>Block name/Color/Entity/Flag/"
  130.         "LAyer/LType/Pick/Style/Thickness/Vector: "))) 
  131.     )
  132.     (setq t2
  133.       (cond
  134.         ((eq t1 "Block")      2)   ((eq t1 "Color")     62)
  135.         ((eq t1 "Entity")     0)   ((eq t1 "LAyer")      8)
  136.         ((eq t1 "LType")      6)   ((eq t1 "Style")      7)
  137.         ((eq t1 "Thickness") 39)   ((eq t1 "Flag" )     66)
  138.         ((eq t1 "Vector")   210)
  139.         (T t1)
  140.       )
  141.     )
  142.     (setq t3
  143.       (cond
  144.         ((= t2  2)  (getstring "\n>>Block name to add/<RETURN to remove>: "))
  145.         ((= t2 62)  (initget 4 "?")
  146.           (cond
  147.             ((or (eq (setq t3 (getint 
  148.               "\n>>Color number to add/?/<RETURN to remove>: ")) "?") 
  149.               (> t3 256))
  150.               (ssx_pc)                ; Print color values.
  151.               nil
  152.             )
  153.             (T
  154.               t3                      ; Return t3.
  155.             )
  156.           )
  157.         )
  158.         ((= t2  0) (getstring "\n>>Entity type to add/<RETURN to remove>: "))
  159.         ((= t2  8) (getstring "\n>>Layer name to add/<RETURN to remove>: "))
  160.         ((= t2  6) (getstring "\n>>Linetype name to add/<RETURN to remove>: "))
  161.         ((= t2  7) 
  162.           (getstring "\n>>Text style name to add/<RETURN to remove>: ")
  163.         )
  164.         ((= t2 39)  (getreal   "\n>>Thickness to add/<RETURN to remove>: "))
  165.         ((= t2 66)  (if (assoc 66 f1) nil 1))
  166.         ((= t2 210) 
  167.           (getpoint  "\n>>Extrusion Vector to add/<RETURN to remove>: ")
  168.         )
  169.         (T          nil)
  170.       )
  171.     )
  172.     (cond
  173.       ((= t2 "Pick") (setq f1 (ssx_fe) t2 nil)) ; get entity
  174.       ((and f1 (assoc t2 f1))         ; already in the list
  175.         (if (and t3 (/= t3 ""))
  176.           ;; Replace with a new value...             
  177.           (setq f1 (subst (cons t2 t3) (assoc t2 f1) f1)) 
  178.           ;; Remove it from filter list...
  179.           (setq f1 (ssx_re (assoc t2 f1) f1)) 
  180.         )  
  181.       )
  182.       ((and t3 (/= t3 ""))
  183.         (setq f1 (cons (cons t2 t3) f1))
  184.       )
  185.       (T nil)
  186.     )
  187.   )
  188.   (if f1 (setq f2 (ssget "x" f1)))
  189.   (setq *error* olderr)
  190.   (if (and f1 f2) 
  191.     (progn
  192.       (princ (strcat "\n" (itoa (sslength f2)) " found. "))
  193.       f2 
  194.     )
  195.     (progn (princ "\n0 found.") (prin1))
  196.   )
  197. )
  198. ;;;
  199. ;;; Print the standard color assignments.
  200. ;;;
  201. ;;;
  202. (defun ssx_pc ()
  203.   (if textpage (textpage) (textscr))
  204.   (princ "\n                                                     ")
  205.   (princ "\n                 Color number   |   Standard meaning ")
  206.   (princ "\n                ________________|____________________")
  207.   (princ "\n                                |                    ")
  208.   (princ "\n                       0        |      <BYBLOCK>     ")
  209.   (princ "\n                       1        |      Red           ")
  210.   (princ "\n                       2        |      Yellow        ")
  211.   (princ "\n                       3        |      Green         ")
  212.   (princ "\n                       4        |      Cyan          ")
  213.   (princ "\n                       5        |      Blue          ")
  214.   (princ "\n                       6        |      Magenta       ")
  215.   (princ "\n                       7        |      White         ")
  216.   (princ "\n                    8...255     |      -Varies-      ")
  217.   (princ "\n                      256       |      <BYLAYER>     ")
  218.   (princ "\n                                               \n\n\n")
  219. )
  220. ;;;
  221. ;;; C: function definition.
  222. ;;;
  223. (defun c:ssx () (ssx)(princ))
  224. (princ "\n\tType \"ssx\" at a Command: prompt or ")
  225. (princ "\n\t(ssx) at any object selection prompt. ")
  226. (princ)
  227.