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 >
Wrap
Text File
|
1989-01-11
|
15KB
|
300 lines
; ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
; A/E Automation Systems ▓▓ ▓▓ ▓▓▓▓▓ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░
; ▓▓▓ ▓▓
; ▓▓▓ ▓▓ ▓▓▓ 32 Gould Avenue
; ▓▓▓ ▓▓ ▓▓ Paterson, N.J. 07503
; ░░░░░░░░░░░░░░░░░░░░░░░░░ ▓▓▓ ▓▓ ▓▓▓▓▓ (201) 523-7944
;
; ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
;
; 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
;
;
; ----------------------------------------------------------------------------
; CONVERT.LSP
; For AutoCAD, Release 9 or 10
; 8/24/88
;
; By Tony Tanzillo, A/E Automation Systems (all rights reserved).
;
; Architectural/Engineering decimal unit conversion utility command to
; convert drawings created with a 1 INCH DRAWING UNIT to drawings created
; with a 1 FOOT DRAWING UNIT, and back.
;
; Deposited into to the public domain on 12/20/88.
;
; Notice.
; ~~~~~~~
; Permission is granted to distribute this file free of charge ONLY
; in its original form as distributed by the author, on any public
; access system. You may not in any way accept payment in exchange
; for this file or it's contents regardless of what form or medium
; it is exchanged in.
;
; Permission is specifically granted to Autodesk Inc. to distribute
; this file and/or make it available to the public as it see's fit,
; provided that due credit is given to the author.
;
; In no way is A/E Automation Systems or Tony Tanzillo responsible in
; any way for the contents of this file, including fitness for any
; specific purpose, or damadges resulting directly or indirectly from
; the use of same. All use of this information is strictly at your own
; risk.
;
; Any incorporation of the information (or any portions thereof) as it
; appears in this file into any commercial products and/or services
; requires the prior expressed WRITTEN consent of the author. Those
; who wish to solicit same, may do so by contacting the author at the
; address included herein. No consent will be granted via telephone.
;
; If you find these utilities of any value, or if you are using them in
; a commercial environment, You can send a donation to help underwrite
; the cost of developing more HIGH PERFORMANCE AutoLISP applications
; and utilities and for the public domain. You will be placed on our
; mailing list and you will be notified when updates are released, and
; you will recieve product information on all of our software applications
; and enhancement products, and our professional AutoLISP programming and
; customization tools for AutoLISP programmers and AutoCAD application
; developers free.
;
; * * * * * * * * Happy Holidays and good luck * * * * * * * *
;
; Tony Tanzillo, A/E Automation Systems
;
; ----------------------------------------------------------------------
;
; What CONVERT does:
; ~~~~~~~~~~~~~~~~~~
; When converting from ARCHITECTURAL units (1 drawing unit = 1 inch) to
; CIVIL ENGINEERING/SURVEYING units (1 drawing unit = 1 foot), the drawing
; must be scaled by a factor of 12.0, or the inverse of 1/12 depending on
; which direction the conversion is being made to. CONVERT automates the
; entire process without requiring you to change any layer settings, or
; select the entire drawing to submit it to the SCALE command. It also
; permits a drawing to store the current state of the decimal units mode
; which it converts between, preventing the drawing from being converted
; more than once in the same direction.
;
; Using CONVERT.
; ~~~~~~~~~~~~~~
; You must load the file "CONVERT.LSP" with (load"convert"), or you
; must add it to your ACAD.LSP file. The first time you use CONVERT
; or UNIT on a particular drawing, there will be no current decimal
; unit mode set for that drawing, and you must specify which mode
; is currently in effect. If the current drawing unit is 1 inch this
; is referred to as "Architectural decimal unit mode", you should then
; respond with "A" when asked to specify the current decimal unit mode.
;
; If the current drawing unit is 1 foot, then this is referred to as
; "Engineering decimal unit mode", and you should respond with "E" when
; asked for the current decimal unit mode. You must select either before
; you can use the CONVERT command. Once you set this mode, it will remian
; with the drawing, and will change each time you CONVERT between the
; the 2 modes. This saved value tells CONVERT what the current decimal
; unit mode is, so it knows which way it should convert. It also serves
; as a safeguard to prevent CONVERT from converting the drawing in the
; same direction more than once (which could cause a BIG problem!).
;
; Initializing the decimal unit mode with the UNIT command.
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; The UNIT command permits you to set the current unit mode without
; performing any conversion. It is recommended that you include this
; command in any SETUP, or AUTO STARTUP sequence for a NEW DRAWING.
; Do not confuse this command with the AutoCAD UNITS command.
;
; To initialize the current unit mode, issue the UNIT command and
; respond with either A or E depending on weather the decimal unit
; that you are working with is currently 1 inch (<A>rchitectural unit
; mode), or 1 foot,(<E>ngineering unit mode). See above for a detailed
; explaination of this mode.
;
; Converting a drawing from one decimal unit mode to the other.
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; If you are an ARCHITECT, and you are sending your site plan to an
; engineer, you should convert it to engineering units first (make sure
; you tell them that you are converting the drawing, so they dont do
; the same when they recieve it!).
;
; If you are an ENGINEER, you have 2 choices: 1. Give this program to
; the architect you are sending your drawings to and let the architect
; be responsible for converting any drawings you send him, or he sends
; you. Or 2. Perform the conversion for them (and notify them about it!).
; This is based on the assumption that your drawing unit represents
; ONE FOOT of course.
;
; If you have already set the current decimal unit mode as described above,
; issue the CONVERT command, and the conversion will be made automatically.
; To prevent repeated conversions in the same direction (a potentially
; catastrophic mistake, causing the drawing to be scaled the same number of
; times), the current `decimal unit mode' is changed, and saved with the
; drawing in a system variable. This safeguard will prevent the drawing
; from being converted more than once in the same direction, provided that
; any such conversion is always performed by the CONVERT command, and not
; via any other means.
;
; Now that the conversion is complete, if you just converted the drawing
; to ARCHITECTURAL decimal unit mode, then each drawing unit will now be
; 1 INCH. If you were converting to ENGINEERING decimal unit mode, each
; drawing unit will now be 1 FOOT. Issuing convert AGAIN will convert the
; drawing back to it's original decimal unit mode. Convert will also scale
; The drawing (everything, including objects on frozen layers) as neccessary
; to maintain dimensional accuracy with the prevailing decimal units mode.
; This will effect your drawing extents, and limits. It is suggested that
; you perform the regen, or zoom extents so that extents, and the virtual
; display is updated. It is also advised that you do not use CONVERT until
; you are ready to save the drawing to be sent to the other party.
;
; To illustrate the effect of CONVERT, load up a new drawing, and set
; units to architectural. Now, draw a line on the display that is approx.
; 12'-6" long. Next, load up CONVERT, and issue the UNIT command, and
; respond with "A" (what you are doing is telling UNIT that this drawing
; is in architectural units mode now). Next issue the CONVERT command.
; you should see the message:
;
; "Converting drawing to ENGINEERING units (new drawing unit = 1 foot)."
;
; You should also see the line you created disappear. Now, ZOOM Extents,
; and the line will be on the display. Remember that when you were in
; architectural units mode, you created a line that was 12'-6" long.
; Now, the drawing is in ENGINEERING units mode, meaning that each
; drawing unit represents one foot on the drawing. LIST the line,
; it's length should be approximately 12.5000 drawing units long.
; Now, issue CONVERT again to switch back into Architectural units mode.
; Again, LIST the line and it's length should be 12'-6", what you had
; originally started out with.
;
; Multi-disciplined.
; ~~~~~~~~~~~~~~~~~~
; If you are an architect doing your own site engineering documents, you
; can store all of these documents on the same drawing which contains the
; floor plans, and switch between the two decimal unit modes as needed.
; But, this approach is not recommended for a large project, or one with
; massive amounts of sitework, since this will result in a large drawing
; that can become hard to deal with. Alternately, you can use this program
; to permit you to transfer only the geometry which represents a building
; envelope and other related structure as it appears on a site plan to a
; floor plan, or the reverse. Use your imagination.
;
; If you are using ANY other 3rd. party software with this program, you
; should refer to the technical information below regarding a possible
; conflict of use of certain system variables.
;
; Good luck and happy holidays,
;
; Tony Tanzillo,
; A/E Automation Systems
;
; -------------------------------------------------------------------------
; Technical information:
;
; The C:CONVERT and C:UNIT functions use the system variables LUNITS
; and JWDEBUG to save and determine the current decimal unit mode as follows:
;
; IF JWdebug = 1
;
; THEN the current drawing unit is 1 INCH (architectural units)
;
; IF JWdebug = 2
;
; THEN the current drawing unit is 1 FOOT (engineering units)
;
; IF JWdebug = 0,
;
; THEN no decimal unit mode has ever been set for the current drawing.
;
; In order to ensure the proper operation of the CONVERT command, you must
; determine that NO OTHER front end application program or other AutoLISP
; program, MENU, or DXF PRE/POSTPROCESSOR writes to the the system variable
; JWDEBUG. If you are currently using any type of 3rd. party, public domain,
; ShareWare, other add-on application program, you should contact a tech
; support rep. for this product, and determine if this system variable is
; used by the application. If it is, then you can still use CONVERT, but you
; must make a change in the program, substituting one of the USERIx SYSTEM
; VARIABLES in place of the string "jwdebug" in the following 2 C:functions.
; You may still want to do this just in case this undocumented variable
; DISSAPPEARS in a future release of AutoCAD (although, my gut feeling is
; that it will not). This is up to you, but you should be sure that the
; variable that is used to store the unit status is also not used by other
; programs.
;
; It is also suggested that you DO NOT SHARE (no joke!) this program with
; those who you exchange drawings with, if thier drawings must be converted.
; Only one of you should have it and the one who does have it should assume
; the responsiblity for all conversions in either direction. You should also
; make sure that you inform the other party that the conversion between units
; has already been made, and that no conversion or scaling of any kind should
; be performed upon recipt of, and proir to submittal of any drawing to or
; from yourself.
;
; Program listing:
; --------------------------------------------------------------------------
(defun C:CONVERT ( / v s h hi cmd)
(setq v "lunits" ; Note -------------------------------
s "jwdebug" ; <--------- PERMANENT STORAGE LOCATION FOR
h "highlight" ; CURRENT DECIMAL UNITS MODE,
hi (getvar h) ; can be changed to any UNUSED
) ; USERIx system variable, i.e: "useri5"
(while (not (member (getvar s)
'(1 2)
)
)
(prompt "\nDecimal unit mode not initialized for this drawing,")
(c:unit)
)
(mapcar 'setvar
(list h "cmdecho" "limcheck")
'(0 0 0)
)
(setq cmd '(".scale" (ssget "x") "" "0,0"))
(prompt "\nConverting drawing to " )
(cond ( (eq 2 (getvar s))
(prompt "ARCHITECTURAL units (new drawing unit = 1 inch).")
(mapcar 'setvar (list s v) '(1 4))
(eval (cons 'command (append cmd (list 12.0))))
)
( (eq 1 (getvar s))
(prompt "ENGINEERING units (new drawing unit = 1 foot).")
(mapcar 'setvar (list s v) '(2 2))
(eval (cons 'command (append cmd (list (recip 12.0)))))
)
(t (prompt "\nNo drawing unit mode set, issue UNIT command."))
)
(setvar h hi)
(prin1)
)
(defun recip (n) (/ 1.0 n)) ; reciprocal of number N,
; (recip <num REAL> )
(defun C:UNIT ( / a d)
(setvar "jwdebug" ; <--------- See above
(cond ( (eq "Architectural"
(progn (initget "Architectural Engineering")
(setq a
(getkword
(strcat "\nSpecify CURRENT decimal unit mode,"
" Architectural/Engineering/<"
(setq d (cond ( (eq 2 (getvar "lunits"))
"E"
)
(t "A")
)
)
">: "
)
)
)
)
)
1
)
( (eq a "Engineering") 2)
( (eq d "A") 1)
(t 2)
)
)
)