Command: GET_DWGUNITS
This function gets current value of DWGUNITS variable responsible for linear measurment units.
Code:
;;; =================================================
;;; GET_DWGUNITS_v2_00.LSP
;;;
;;; Written by Andrzej Kalinowski, www.autolisps.blogspot.com
;;; v1.00 - 23.03.2019
;;; v1.04 - 30.03.2019
;;; v2.00 - 23.07.2022 - misc code improvements
;;;
;;; Function gets drawing units value.
;;; Program checks if this variable exists - in this way the main routine will not be limmited to work only in Autocad, where this variable is native
;;; =================================================
(defun GET_DWGUNITS ( / old_cmdecho7 dwgunts )
;;; 1. Inches
;;; 2. Feet
;;; 3. Millimeters
;;; 4. Centimeters
;;; 5. Decimetersw
;;; 6. Meters
;-----------------------------------------
(if (getcname "_-dwgunits")
(progn
(setq old_cmdecho7 (getvar "cmdecho") );setq
(setvar "cmdecho" 1);necessary to read last prompt
(command "_-dwgunits" );command
(command);breaking command
(graphscr)
(setq dwgunts (getvar "lastprompt") )
(setvar "cmdecho" old_cmdecho7)
(atoi (substr dwgunts (+ (vl-string-search "<" dwgunts) 2) (- (vl-string-search ">" dwgunts) (vl-string-search "<" dwgunts) 1) ))
);progn
);if
);defun
Download file: GET_DWGUNITS_v2_00.LSP
No comments:
Post a Comment