GET_DWGUNITS_v4_00.....................................free

Command: GET_DWGUNITS

This function gets current value of DWGUNITS variable responsible for linear measurment units.

 

Code:

;;; =================================================
;;;        GET_DWGUNITS_v4_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
;;;        v3.00 - 09.11.2025 - added closing of the Text Window
;;;        v4.00 - 27.09.2026 - program adjusted to work with Gstarcad 2025 an newer vewrsions
;;;
;;;        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
;;; =================================================
(vl-load-com)
(defun GET_DWGUNITS ( /  old_cmde1 dwgunts1 )
;;;    1. Inches
;;;    2. Feet
;;;    3. Millimeters
;;;    4. Centimeters
;;;    5. Decimetersw
;;;    6. Meters
    ;-----------------------------------------
    (if (getcname "_-dwgunits")
        (progn
            (setq old_cmde1 (getvar "cmdecho") );setq
            (setvar "cmdecho" 1);necessary to read last prompt 
            (cond ;this condition checks if the drawing is opened in Gstarcad or other App like Autocad or other. There are differences in understanding "lasptopmpt" in Gstarcad and Autocad.
                ((wcmatch (strcase (vla-get-name (vlax-get-acad-object))) "*GSTARCAD*")
                    (command "_-dwgunits"  ) (setq dwgunts1 (getvar "lastprompt") ) (command)   )
                (t
                    (command "_-dwgunits" ) (command) (setq dwgunts1 (getvar "lastprompt") ) )
            );cond
            (vl-cmdf "_.Textscr"); Toggles Text Window on/off. (toggle since 2014)
            (setvar "cmdecho" old_cmde1)
            (graphscr)
            (atoi (substr dwgunts1 (+ (vl-string-search "<" dwgunts1) 2) (- (vl-string-search ">" dwgunts1) (vl-string-search "<" dwgunts1) 1) ))
        );progn
    );if
);defun




Download file: GET_DWGUNITS_v4_00.LSP

No comments:

Post a Comment