This function gets current AECBOSMODE value. This variable is native to Autocad MEP.
The Lisp program checks if this variable exists - in this way the main routine where GET_AECBOSMODE is a subroutine will be universal for any lisp supproting software.
Code:
;;; ================================================= ;;; GET_AECBOSMODE_v3_00.LSP ;;; ;;; Written by Andrzej Kalinowski, www.autolisps.blogspot.com ;;; v1.00 - 02.08.2015 - first release ;;; v1.01 - 19.02.2019 - adjusting to work with alternative to autocad programs ;;; v2.00 - 28.07.2020 - adding (getcname ) to hide "unknown command" error if command is unknown ;;; v3.00 - 23.07.2022 - misc code improvements ;;; ;;; Function gets AECBOSMODE value ;;; Program checks if this variable exists - in this way the main routine will not be limmited to work only in Autocad MEP, where this variable is native ;;; ================================================= (vl-load-com) (defun GET_AECBOSMODE ( / AecbOM old_cmdecho998) (if (getcname "AECBOSMODE") (progn (setq old_cmdecho998 (getvar "CMDECHO")) (setvar "CMDECHO" 1);necessary to read last prompt with the urrent AECBOSMODE (command "AECBOSMODE" ) (command);breaks command (setq AecbOM (getvar "lastprompt") ) ; returns fe. "Enter new value for AECBOSMODE <1023>:" (setvar "CMDECHO" old_cmdecho998);restoring cmdecho (atoi (substr AecbOM (+ (vl-string-search "<" AecbOM) 2) (- (vl-string-search ">" AecbOM) (vl-string-search "<" AecbOM) 1) ) ) );progn );if );defun ;;; ================================================= ;| ;;;this line you put in your program to save AECBOSMODE before changing it (setq old_aecbosmode (GET_AECBOSMODE) ) ;;;this line you put in your program to change AECBOSMODE to f.e. 0 (if old_aecbosmode (command "AECBOSMODE" 0) ) ;;;this line you put in your program to restore the previous aecbosmode (if old_aecbosmode (command "AECBOSMODE" old_aecbosmode) ) ;;;optionally - this line you put in your program in the error trapper to restore the previous aecbosmode ;;;checks if command-s is recognised to work with older autocad versions. Prevents error: Cannot invoke (command) from *error* (if old_aecbosmode (if (not command-s) (command "aecbosmode" old_aecbosmode) (command-s "aecbosmode" old_aecbosmode) ) ) |; 1023>
Example:
Download file: GET_AECBOSMODE_v3_00.LSP
No comments:
Post a Comment