home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / GR / GR505.ZIP / LSP.EXE / CONVERT.LSP < prev    next >
Text File  |  1989-01-11  |  15KB  |  300 lines

  1. ; ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  2. ; A/E Automation Systems             ▓▓ ▓▓ ▓▓▓▓▓  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  3. ;                                  ▓▓▓  ▓▓
  4. ;                                ▓▓▓    ▓▓ ▓▓▓           32 Gould Avenue
  5. ;                              ▓▓▓   ▓▓ ▓▓               Paterson, N.J.  07503
  6. ; ░░░░░░░░░░░░░░░░░░░░░░░░░  ▓▓▓        ▓▓ ▓▓▓▓▓         (201) 523-7944
  7. ;
  8. ; ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  9. ;
  10. ; d e s i g n            a u t o m a t i o n             c o n s u l t a n t s
  11. ;
  12. ;
  13. ; ----------------------------------------------------------------------------
  14. ; CONVERT.LSP
  15. ; For AutoCAD, Release 9 or 10
  16. ; 8/24/88
  17. ;
  18. ; By Tony Tanzillo, A/E Automation Systems             (all rights reserved).
  19. ;
  20. ; Architectural/Engineering decimal unit conversion utility command to
  21. ; convert drawings created with a 1 INCH DRAWING UNIT to drawings created
  22. ; with a 1 FOOT DRAWING UNIT, and back.
  23. ;
  24. ; Deposited into to the public domain on 12/20/88.
  25. ;
  26. ; Notice.
  27. ; ~~~~~~~
  28. ; Permission is granted to distribute this file free of charge ONLY
  29. ; in its original form as distributed by the author, on any public
  30. ; access system. You may not in any way accept payment in exchange
  31. ; for this file or it's contents regardless of what form or medium
  32. ; it is exchanged in.
  33. ;
  34. ; Permission is specifically granted to Autodesk Inc. to distribute
  35. ; this file and/or make it available to the public as it see's fit,
  36. ; provided that due credit is given to the author.
  37. ;
  38. ; In no way is A/E Automation Systems or Tony Tanzillo responsible in
  39. ; any way for the contents of this file, including fitness for any
  40. ; specific purpose, or damadges resulting directly or indirectly from
  41. ; the use of same. All use of this information is strictly at your own
  42. ; risk.
  43. ;
  44. ; Any incorporation of the information (or any portions thereof) as it
  45. ; appears in this file into any commercial products and/or services
  46. ; requires the prior expressed WRITTEN consent of the author. Those
  47. ; who wish to solicit same, may do so by contacting the author at the
  48. ; address included herein. No consent will be granted via telephone.
  49. ;
  50. ; If you find these utilities of any value, or if you are using them in
  51. ; a commercial environment, You can send a donation to help underwrite
  52. ; the cost of developing more HIGH PERFORMANCE AutoLISP applications
  53. ; and utilities and for the public domain. You will be placed on our
  54. ; mailing list and you will be notified when updates are released, and
  55. ; you will recieve product information on all of our software applications
  56. ; and enhancement products, and our professional AutoLISP programming and
  57. ; customization tools for AutoLISP programmers and AutoCAD application
  58. ; developers free.
  59. ;
  60. ; * * * * * * * *       Happy Holidays and good luck       * * * * * * * *
  61. ;
  62. ; Tony Tanzillo, A/E Automation Systems
  63. ;
  64. ; ----------------------------------------------------------------------
  65. ;
  66. ; What CONVERT does:
  67. ; ~~~~~~~~~~~~~~~~~~
  68. ;   When converting from ARCHITECTURAL units (1 drawing unit = 1 inch) to
  69. ;   CIVIL ENGINEERING/SURVEYING units (1 drawing unit = 1 foot), the drawing
  70. ;   must be scaled by a factor of 12.0, or the inverse of 1/12 depending on
  71. ;   which direction the conversion is being made to. CONVERT automates the
  72. ;   entire process without requiring you to change any layer settings, or
  73. ;   select the entire drawing to submit it to the SCALE command. It also
  74. ;   permits a drawing to store the current state of the decimal units mode
  75. ;   which it converts between, preventing the drawing from being converted
  76. ;   more than once in the same direction.
  77. ;
  78. ; Using CONVERT.
  79. ; ~~~~~~~~~~~~~~
  80. ;   You must load the file "CONVERT.LSP" with (load"convert"), or you
  81. ;   must add it to your ACAD.LSP file. The first time you use CONVERT
  82. ;   or UNIT on a particular drawing, there will be no current decimal
  83. ;   unit mode set for that drawing, and you must specify which mode
  84. ;   is currently in effect. If the current drawing unit is 1 inch this
  85. ;   is referred to as "Architectural decimal unit mode", you should then
  86. ;   respond with "A" when asked to specify the current decimal unit mode.
  87. ;
  88. ;   If the current drawing unit is 1 foot, then this is referred to as
  89. ;   "Engineering decimal unit mode", and you should respond with "E" when
  90. ;   asked for the current decimal unit mode. You must select either before
  91. ;   you can use the CONVERT command. Once you set this mode, it will remian
  92. ;   with the drawing, and will change each time you CONVERT between the
  93. ;   the 2 modes. This saved value tells CONVERT what the current decimal
  94. ;   unit mode is, so it knows which way it should convert. It also serves
  95. ;   as a safeguard to prevent CONVERT from converting the drawing in the
  96. ;   same direction more than once (which could cause a BIG problem!).
  97. ;
  98. ;   Initializing the decimal unit mode with the UNIT command.
  99. ;   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100. ;   The UNIT command permits you to set the current unit mode without
  101. ;   performing any conversion. It is recommended that you include this
  102. ;   command in any SETUP, or AUTO STARTUP sequence for a NEW DRAWING.
  103. ;   Do not confuse this command with the AutoCAD UNITS command.
  104. ;
  105. ;   To initialize the current unit mode, issue the UNIT command and
  106. ;   respond with either A or E depending on weather the decimal unit
  107. ;   that you are working with is currently 1 inch (<A>rchitectural unit
  108. ;   mode), or 1 foot,(<E>ngineering unit mode). See above for a detailed
  109. ;   explaination of this mode.
  110. ;
  111. ;   Converting a drawing from one decimal unit mode to the other.
  112. ;   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  113. ;   If you are an ARCHITECT, and you are sending your site plan to an
  114. ;   engineer, you should convert it to engineering units first (make sure
  115. ;   you tell them that you are converting the drawing, so they dont do
  116. ;   the same when they recieve it!).
  117. ;
  118. ;   If you are an ENGINEER, you have 2 choices: 1. Give this program to
  119. ;   the architect you are sending your drawings to and let the architect
  120. ;   be responsible for converting any drawings you send him, or he sends
  121. ;   you. Or 2. Perform the conversion for them (and notify them about it!).
  122. ;   This is based on the assumption that your drawing unit represents
  123. ;   ONE FOOT of course.
  124. ;
  125. ;   If you have already set the current decimal unit mode as described above,
  126. ;   issue the CONVERT command, and the conversion will be made automatically.
  127. ;   To prevent repeated conversions in the same direction (a potentially
  128. ;   catastrophic mistake, causing the drawing to be scaled the same number of
  129. ;   times), the current `decimal unit mode' is changed, and saved with the
  130. ;   drawing in a system variable. This safeguard will prevent the drawing
  131. ;   from being converted more than once in the same direction, provided that
  132. ;   any such conversion is always performed by the CONVERT command, and not
  133. ;   via any other means.
  134. ;
  135. ;   Now that the conversion is complete, if you just converted the drawing
  136. ;   to ARCHITECTURAL decimal unit mode, then each drawing unit will now be
  137. ;   1 INCH. If you were converting to ENGINEERING decimal unit mode, each
  138. ;   drawing unit will now be 1 FOOT. Issuing convert AGAIN will convert the
  139. ;   drawing back to it's original decimal unit mode. Convert will also scale
  140. ;   The drawing (everything, including objects on frozen layers) as neccessary
  141. ;   to maintain dimensional accuracy with the prevailing decimal units mode.
  142. ;   This will effect your drawing extents, and limits. It is suggested that
  143. ;   you perform the regen, or zoom extents so that extents, and the virtual
  144. ;   display is updated. It is also advised that you do not use CONVERT until
  145. ;   you are ready to save the drawing to be sent to the other party.
  146. ;
  147. ;   To illustrate the effect of CONVERT, load up a new drawing, and set
  148. ;   units to architectural. Now, draw a line on the display that is approx.
  149. ;   12'-6" long. Next, load up CONVERT, and issue the UNIT command, and
  150. ;   respond with "A" (what you are doing is telling UNIT that this drawing
  151. ;   is in architectural units mode now). Next issue the CONVERT command.
  152. ;   you should see the message:
  153. ;
  154. ;   "Converting drawing to ENGINEERING units (new drawing unit = 1 foot)."
  155. ;
  156. ;   You should also see the line you created disappear. Now, ZOOM Extents,
  157. ;   and the line will be on the display. Remember that when you were in
  158. ;   architectural units mode, you created a line that was 12'-6" long.
  159. ;   Now, the drawing is in ENGINEERING units mode, meaning that each
  160. ;   drawing unit represents one foot on the drawing. LIST the line,
  161. ;   it's length should be approximately 12.5000 drawing units long.
  162. ;   Now, issue CONVERT again to switch back into Architectural units mode.
  163. ;   Again, LIST the line and it's length should be 12'-6", what you had
  164. ;   originally started out with.
  165. ;
  166. ;   Multi-disciplined.
  167. ;   ~~~~~~~~~~~~~~~~~~
  168. ;   If you are an architect doing your own site engineering documents, you
  169. ;   can store all of these documents on the same drawing which contains the
  170. ;   floor plans, and switch between the two decimal unit modes as needed.
  171. ;   But, this approach is not recommended for a large project, or one with
  172. ;   massive amounts of sitework, since this will result in a large drawing
  173. ;   that can become hard to deal with.  Alternately, you can use this program
  174. ;   to permit you to transfer only the geometry which represents a building
  175. ;   envelope and other related structure as it appears on a site plan to a
  176. ;   floor plan, or the reverse. Use your imagination.
  177. ;
  178. ;   If you are using ANY other 3rd. party software with this program, you
  179. ;   should refer to the technical information below regarding a possible
  180. ;   conflict of use of certain system variables.
  181. ;
  182. ;   Good luck and happy holidays,
  183. ;
  184. ;   Tony Tanzillo,
  185. ;   A/E Automation Systems
  186. ;
  187. ; -------------------------------------------------------------------------
  188. ; Technical information:
  189. ;
  190. ; The C:CONVERT and C:UNIT functions use the system variables LUNITS
  191. ; and JWDEBUG to save and determine the current decimal unit mode as follows:
  192. ;
  193. ; IF JWdebug = 1
  194. ;
  195. ;    THEN the current drawing unit is 1 INCH (architectural units)
  196. ;
  197. ; IF JWdebug = 2
  198. ;
  199. ;    THEN the current drawing unit is 1 FOOT (engineering units)
  200. ;
  201. ; IF JWdebug = 0,
  202. ;
  203. ;    THEN no decimal unit mode has ever been set for the current drawing.
  204. ;
  205. ; In order to ensure the proper operation of the CONVERT command, you must
  206. ; determine that NO OTHER front end application program or other AutoLISP
  207. ; program, MENU, or DXF PRE/POSTPROCESSOR writes to the the system variable
  208. ; JWDEBUG. If you are currently using any type of 3rd. party, public domain,
  209. ; ShareWare, other add-on application program, you should contact a tech
  210. ; support rep. for this product, and determine if this system variable is
  211. ; used by the application. If it is, then you can still use CONVERT, but you
  212. ; must make a change in the program, substituting one of the USERIx SYSTEM
  213. ; VARIABLES in place of the string "jwdebug" in the following 2 C:functions.
  214. ; You may still want to do this just in case this undocumented variable
  215. ; DISSAPPEARS in a future release of AutoCAD (although, my gut feeling is
  216. ; that it will not). This is up to you, but you should be sure that the
  217. ; variable that is used to store the unit status is also not used by other
  218. ; programs.
  219. ;
  220. ; It is also suggested that you DO NOT SHARE (no joke!) this program with
  221. ; those who you exchange drawings with, if thier drawings must be converted.
  222. ; Only one of you should have it and the one who does have it should assume
  223. ; the responsiblity for all conversions in either direction. You should also
  224. ; make sure that you inform the other party that the conversion between units
  225. ; has already been made, and that no conversion or scaling of any kind should
  226. ; be performed upon recipt of, and proir to submittal of any drawing to or
  227. ; from yourself.
  228. ;
  229. ; Program listing:
  230. ; --------------------------------------------------------------------------
  231.  
  232.  
  233. (defun C:CONVERT ( / v s h hi cmd)
  234.   (setq v  "lunits"                   ; Note -------------------------------
  235.         s  "jwdebug"   ;     <--------- PERMANENT STORAGE LOCATION FOR
  236.         h  "highlight"                ; CURRENT DECIMAL UNITS MODE,
  237.         hi (getvar h)                 ; can be changed to any UNUSED
  238.   )                                   ; USERIx system variable, i.e: "useri5"
  239.   (while (not (member (getvar s)
  240.                      '(1 2)
  241.               )
  242.          )
  243.          (prompt "\nDecimal unit mode not initialized for this drawing,")
  244.          (c:unit)
  245.   )
  246.   (mapcar 'setvar
  247.            (list h "cmdecho" "limcheck")
  248.           '(0 0 0)
  249.   )
  250.   (setq cmd '(".scale" (ssget "x") "" "0,0"))
  251.   (prompt "\nConverting drawing to " )
  252.   (cond (  (eq 2 (getvar s))
  253.            (prompt "ARCHITECTURAL units (new drawing unit = 1 inch).")
  254.            (mapcar 'setvar (list s v) '(1 4))
  255.            (eval (cons 'command (append cmd (list 12.0))))
  256.         )
  257.         (  (eq 1 (getvar s))
  258.            (prompt "ENGINEERING units (new drawing unit = 1 foot).")
  259.            (mapcar 'setvar (list s v) '(2 2))
  260.            (eval (cons 'command (append cmd (list (recip 12.0)))))
  261.         )
  262.         (t (prompt "\nNo drawing unit mode set, issue UNIT command."))
  263.   )
  264.   (setvar h hi)
  265.   (prin1)
  266. )
  267.  
  268. (defun recip (n) (/ 1.0 n))                ; reciprocal of number N,
  269.                                            ; (recip <num REAL> )
  270.  
  271. (defun C:UNIT ( / a d)
  272.    (setvar "jwdebug"                       ; <--------- See above
  273.       (cond ( (eq "Architectural"
  274.                   (progn (initget "Architectural Engineering")
  275.                          (setq a
  276.                             (getkword
  277.                                (strcat "\nSpecify CURRENT decimal unit mode,"
  278.                                        " Architectural/Engineering/<"
  279.                                        (setq d (cond ( (eq 2 (getvar "lunits"))
  280.                                                        "E"
  281.                                                      )
  282.                                                      (t "A")
  283.                                                )
  284.                                        )
  285.                                        ">: "
  286.                                )
  287.                             )
  288.                          )
  289.                   )
  290.               )
  291.               1
  292.             )
  293.             ( (eq a "Engineering") 2)
  294.             ( (eq d "A") 1)
  295.             (t 2)
  296.       )
  297.    )
  298. )
  299.