home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / GR / GR505.ZIP / LSP.EXE / PROP.LSP < prev    next >
Text File  |  1987-07-12  |  6KB  |  196 lines

  1. ; PROP.LSP
  2. ; 1/10/87
  3. ; Tony Tanzillo
  4. ;
  5. ; Do you often forget the names of layers and linetypes, or
  6. ; What elevation or thickness you were drawing at half an hour ago?
  7. ;
  8. ; PROP.LSP contains macro fuctions that can take the place of keyboard
  9. ; entered properties such as LAYER, COLOR, LINETYPE, THICKNESS,
  10. ; and ELEVATION. They can be used _WHENEVER_ AutoCAD is requesting
  11. ; input of one of those properties, Simply type in the appropriate
  12. ; function name, and select an object, the appropriate property of
  13. ; that object is supplied to AutoCAD just as if You had entered
  14. ; it manually from the keyboard, or picked it from a tablet.
  15. ;
  16. ; There is an underlying and very basic concept that is critical
  17. ; to the way that Humans interact with a computer of any kind.
  18. ; That basic concept is that it is EASIER TO POINT to something that
  19. ; has a logical association with what it is your trying to tell the
  20. ; computer.
  21. ; These fuctions borrow on this concept by taking the approach of
  22. ; TREATING THE OBJECTS ON THE DISPLAY AS IF THEY WERE A KIND OF MENU.
  23. ; They all posses the 5 basic entity properties (LAYER COLOR LINETYPE
  24. ; ELEVATION and THICKNESS) and, therefore, when AutoCAD is asking YOU
  25. ; for the NAME that you gave one of those properties, You can tell it
  26. ; where to look for something, knowing that there it will be found.
  27. ;
  28. ; Examples of useage
  29. ; ------------------
  30. ;
  31. ;  ( [<] represents a Carriage return, user input is in cap's)
  32. ;
  33. ;  Example 1
  34. ;  ---------
  35. ;  Command: COLOR <
  36. ;  New entity color <BYLAYER>: (color) <
  37. ;  Select object: <do so>
  38. ;  Command:
  39. ;
  40. ;  <The color of the selected object becomes the new current color>
  41. ;   (it get's better)
  42. ;
  43. ;  Example 2
  44. ;  ---------
  45. ;
  46. ;  Command: LINETYPE <
  47. ;  ?/Create/Load/Set: S <
  48. ;  New entity linetype (or ?) <HIDDEN>: (LINETYPE) <
  49. ;  Select object: <Do so!>
  50. ;  ?/Create/Load/Set: <
  51. ;  Command:
  52. ;
  53. ;  <the linetype of the selected object becomes the new current linetype>
  54. ;
  55. ;  Example 3
  56. ;  ---------
  57. ;
  58. ;  Command: LAYER
  59. ;  ?/Make/Set/New/ON/OFF/Color/Ltype/Freeze/Thaw: S <
  60. ;  New current layer <WOOD>: (LAYER) <
  61. ;  Select object: <do so>
  62. ;  ?/Make/Set/New/ON/OFF/Color/Ltype/Freeze/Thaw: <
  63. ;  Command:
  64. ;
  65. ;     <sets the layer of the selected object to the current layer>
  66. ;
  67. ;  Example 4
  68. ;  ---------
  69. ;
  70. ;  Command: LAYER <
  71. ;  ?/Make/Set/New/ON/OFF/Color/Ltype/Freeze/Thaw: OFF <
  72. ;  Layer name(s) to turn Off: (layers) <
  73. ;  Select objects: C <
  74. ;  First corner: Other corner: 7 found.
  75. ;  Select objects: <
  76. ;  ?/Make/Set/New/ON/OFF/Color/Ltype/Freeze/Thaw: <
  77. ;
  78. ;  <ALL layers on which the selected objects reside are turned off>
  79. ;
  80. ;  Other valid uses
  81. ;  ----------------
  82. ;
  83. ;  1. Any property response to the CHANGE command's properties option.
  84. ;
  85. ;  2. Any LAYER sub command except ON, THAW, MAKE, & NEW (not applicable)
  86. ;
  87. ;  * Note:  Use (layerS) ONLY when multiple comma-delimited
  88. ;           layer names are a valid response to the prompt, as
  89. ;           in LAYER FREEZE layr1,layr2,layr3... (actually
  90. ;           the only real uses of (layerS) is LAYER OFF or
  91. ;           LAYER FREEZE since you cannot select objects on
  92. ;           layers that are off or frozen).
  93. ;
  94. ;           Use (layer) for prompts which accept only a single
  95. ;           layer name.
  96. ;
  97. ;  3. The COLOR Command (as shown above)
  98. ;
  99. ;  4. The LINETYPE Command (as shown above)
  100. ;
  101. ;  5. The ELEV Command (elev. & thickness)
  102. ;
  103. ;   There may be other uses ..........
  104. ;
  105. ;  Notes.....
  106. ;  Objects with UNDEFINED elvation and thickness, as well as
  107. ;  color and linetype properties which are defined as "BYLAYER"
  108. ;  do not apply to any of these functions, If you select an object
  109. ;  of this type, the fuction will return a carriage return, which
  110. ;  in most cases, signals acceptance of the default value of the prompt
  111. ;  which is displyed in brackets thusly; <DEFAULT>, and nothing
  112. ;  will happen.
  113. ;
  114. ;  Most of these commands are also good as a "quick inquiry"
  115. ;  for one particular property from the Command: prompt, example:
  116. ;
  117. ;  Command: (layer)
  118. ;  Select object: <do so> "LAYERNAME" <layer of selected object is displayed>
  119. ;  Command:
  120. ;
  121. ;
  122. ;                                           Tony Tanzillo, 70307,2556
  123. ;
  124. ;  support functions
  125.  
  126.  
  127. (defun pfetch(e p)                 ; general purpose property fetcher
  128.   (cond
  129.     ((atom p)
  130.        (cdr
  131.          (assoc p
  132.            (entget (cond ((eq (type e) 'ENAME) e) ((car e))))
  133.          )
  134.        )
  135.     )
  136.     ((mapcar '(lambda(x) (pfetch e x )) p))
  137.   )
  138. )
  139.  
  140. (defun sslist (ss / elst i s)                ; returns a list of enames
  141.   (setq elst '() i -1 s (sslength ss))       ; from a pickset
  142.   (while (< (setq i (1+ i)) s)
  143.     (setq elst (cons (ssname ss i) elst))
  144.   )
  145. )
  146.  
  147. (defun orr(l) (eval (cons 'cond (mapcar 'list l)))) ; Common Lisp
  148.  
  149.  
  150. ; Keyword option fuctions.... Can be entered at the appropriate prompt
  151. ; ---------------------------------------------------------------------
  152.  
  153. (defun layer()         ; use anytime AutoCAD asks for the name of 1 LAYER
  154.   (pfetch (entsel) 8)
  155. )
  156.  
  157. (defun color()                     ; use anytime AutoCAD asks for a color.
  158.   (orr '((pfetch (entsel) 62) "BYLAYER "))
  159. )
  160.  
  161. (defun linetype()                  ; use anytime AutoCAD asks for a linetype.
  162.   (orr '((pfetch (entsel) 6) ""))
  163. )
  164.  
  165. (defun elev()                      ; use anytime AutoCAD asks for an elev.
  166.   (orr '((pfetch (entsel) 38) ""))
  167. )
  168.  
  169. (defun thick()                     ; get the picture?
  170.   (orr '((pfetch (entsel) 39) ""))
  171. )
  172.  
  173. ; Note the (layers) function will supply a string containing the
  174. ; names of multiple layers which are all the layer properties of
  175. ; the objects you select in response to "Select Objects:".
  176. ;
  177. ; Don't select too many objects, and try to avoid selecting more than
  178. ; one object with the same layer property. This is because the input
  179. ; string returned by (layers) cannot be more than 80 bytes.
  180. ;
  181. ; The only practicle uses for this one are LAYER OFF and LAYER FREEZE.
  182.  
  183. (defun layers(/ a b)
  184.   (setq a (mapcar '(lambda (x) (pfetch x 8)) (sslist (ssget))))
  185.   (strcat (car a)
  186.     (apply 'strcat
  187.       (mapcar '(lambda (l c) (strcat c l ))
  188.         (cdr a)
  189.         (mapcar '(lambda (x) ",") (cdr a))
  190.       )
  191.     )
  192.   )
  193. )
  194.  THICKNESS) and, therefore, when AutoCAD is asking YOU
  195. ; for the NAME that you gave one of those properties, You can tell it
  196.