Ok I have this program that will blink a selected layer. The problem is that if I hit esc the program will not go to the Reset_env sub to reset the layer color etc. What it the problem I've been looking at this thing for about an hour.
hl.lsp
;;; ------------------------------------------------------------------------
;;; HL.LSP Version 1.1
;;;
;;; Copyright (C) SEPTEMBER, 2001
;;; Timothy G. Spangler
;;;
;;; Permission to use, copy, modify, and distribute this software
;;; for any purpose and without fee is hereby granted, provided
;;; that the above copyright notice appears in all copies and
;;; that both that copyright notice appear in all supporting documents.
;;;
;;; Blinks Selected Layer
;;;
;;; ------------------------------------------------------------------------
(defun wait (seconds / stop) ; Pause Routine Thanks to Tony
; Tanzillo
(setq stop (+ (getvar "DATE") (/ seconds 86400.0)))
(while (> stop (getvar "DATE"))
(princ)
)
)
;;; End defun
;;;
(defun c:hl (/ *error* blink hlini obj off old_cmdecho old_error old_layer
old_regenmode old_uscicon on path version
) ; Set the Env for Use
;; Error Handling Routine
(defun *error* (Msg)
(if (not (member Msg '("Function cancelled" "quit / exit abort")))
(princ (strcat "\n*** Program Error: " (strcase Msg) " ***"))
(princ "\n... Program Cancelled ...")
)
(while (< 0 (getvar "cmdactive"))
(command)
)
(RESET_ENV)
(princ)
)
(command "_undo" "BE")
(setq old_cmdecho (getvar "cmdecho"))
(setq old_layer (getvar "clayer"))
(setq old_regenmode (getvar "regenmode"))
(setq old_uscicon (getvar "ucsicon"))
(setvar "cmdecho" 0)
(setvar "regenmode" 0)
(setvar "ucsicon" 0)
(setq path "C:/Acad Toolbox/Menu Files/Layer Tools/") ;;<-------CHANGE THIS HARD CODED PATH
(setq obj (car (entsel "\nPick layer to HIGHLIGHT or [ENTER] for Options: ")))
(if (findfile (strcat path "HL.ini")) ; Begin if
(progn ; Retrieves information from INI
; file
(princ "\nRetrieving Configuration...Please Wait. ")
(wait 0.5)
(setq hlini (open (strcat path "HL.ini") "r"))
(read-line hlini)
(setq version (read-line hlini))
(read-line hlini)
(read-line hlini)
(setq on (atoi (read-line hlini)))
(read-line hlini)
(setq off (atoi (read-line hlini)))
(read-line hlini)
(setq blink (atof (read-line hlini)))
(close hlini)
) ; End progn
(progn ; Creates INI file
(princ "\nCreating Config file...Please Wait. ")
(wait 0.5)
(setq hlini (open (strcat path "HL.ini") "w"))
(write-line "Configuration File for Highlight Layer Lisp" hlini)
(write-line "Highlight Layer v1.1 " hlini)
(write-line "\nBlink On" hlini)
(write-line "7" hlini)
(write-line "Blink Off" hlini)
(write-line "250" hlini)
(write-line "Blink Speed" hlini)
(write-line "0.5" hlini)
(close hlini)
(setq on 7)
(setq off 250)
(setq blink 0.5)
(setq version "Highlight Layer v1.1 ")
) ; End progn
) ; End if
(pick)
)
;;; End defun
;;;
(defun dialog (/ dcl_id end_dialog) ; Starts Dialog Session
(setq DCL_ID (load_dialog "hl.dcl"))
(if (not (new_dialog "hl" DCL_ID))
(exit)
) ; End if
(image)
(set_tile "message" version)
(set_tile "blinker" (rtos blink 2 2))
(action_tile "blinkon" "(done_dialog 5)")
(action_tile "blinkoff" "(done_dialog 6)")
(action_tile "blinker" "(setq blink (atof $value))")
(action_tile "accept" "(done_dialog 3)")
(action_tile "cancel" "(done_dialog 4)")
(setq end_dialog (start_dialog))
(cond ; Begin cond
((= end_dialog 5) ; Sets blink on color
(setq on (acad_colordlg 7 nil))
(dialog)
)
((= end_dialog 6) ; Sets blink off color
(setq off (acad_colordlg 7 nil))
(dialog)
)
((= end_dialog 3) ; <OK>
(save_ini)
(setq obj (car (entsel "\nPick layer to HIGHLIGHT: ")))
(pick)
)
((= end_dialog 4) ; <CANCEL>
(princ "\n User Cancelled!")
)
) ; End cond
)
;;; End defun
;;;
(defun pick (/ layr layrcolor) ; Allows user to select object
(if (= (type obj) nil)
(dialog)
(progn ; Begin progn
(setq layr (cdr (assoc 8 (entget obj))))
(setq layrcolor (cdr (assoc 62 (tblsearch "layer" layr))))
(repeat 5 ; Begin repeat
(command ".layer" "s" layr "c" on "" "")
(wait blink)
(command ".layer" "s" layr "c" off "" "")
(wait blink)
) ; End repeat
(princ (strcat "\nThe highlighted layer was: " layr))
) ; End progn
) ; End if
(reset_env)
)
;;; End defun
;;;
(defun image (/ offcol offhgt offwid oncol onhgt onwid) ; Sets blink on/off
; color swatches
(setq onwid (dimx_tile "blinkon")) ; Begin Blink ON
(setq onhgt (dimx_tile "blinkon"))
(setq oncol on)
(start_image "blinkon")
(fill_image 0 0 onwid onhgt oncol)
(end_image) ; End Blink ON
(setq offwid (dimx_tile "blinkoff")) ; Begin Blink OFF
(setq offhgt (dimx_tile "blinkoff"))
(setq offcol off)
(start_image "blinkoff")
(fill_image 0 0 offwid offhgt offcol)
(end_image) ; End Blink OFF
)
;;; End defun
;;;
(defun save_ini (/ hlini) ; Saves Confinguration to INI file
(if (findfile(strcat path "HL.ini")) ; Begin if
(progn ; Begin progn
(princ "\nSaving Configuration...Please Wait. ")
(wait 0.5)
(setq hlini (open (strcat path "hl.ini") "w"))
(write-line "Configuration File for Highlight Layer Lisp" hlini)
(write-line "Highlight Layer v1.1 " hlini)
(write-line "\nBlink On" hlini)
(write-line (rtos on 2 0) hlini)
(write-line "Blink Off" hlini)
(write-line (rtos off 2 0) hlini)
(write-line "Blink Speed" hlini)
(write-line (rtos blink 2 2) hlini)
(close hlini)
) ; End progn
) ; End if
)
;;; End defun
;;;
(defun RESET_ENV (/) ; Reset env
(command "_undo" "END")
(setvar "clayer" old_layer)
(setvar "regenmode" old_regenmode)
(setvar "ucsicon" old_uscicon)
(command ".layer" "c" layrcolor layr "")
(setvar "cmdecho" old_cmdecho)
(princ)
)
;;; End defun
;;;
;;; Echos to the command line
(princ "\nHighlight Layer v1.1 \n(c)Timothy Spangler, \nSeptember, 2001....loaded.")
;;; End echo
hl.dcl
/// ------------------------------------------------------------------------
/// HL.DCL Version 1.0
///
/// Copyright (C) SEPTEMBER, 2001
/// Timothy G. Spangler
///
/// Permission to use, copy, modify, and distribute this software
/// for any purpose and without fee is hereby granted, provided
/// that the above copyright notice appears in all copies and
/// that both that copyright notice and the limited warranty and
/// restricted rights notice below appear in all supporting
/// documentation.
///
/// Used to get information for HL.lsp
///
/// ------------------------------------------------------------------------
hl:dialog{
label = "Layer Highlight Options";
:boxed_column{
label = "On/Off Colors";
:row{
:text{
label = "Blink On Color";
}
:image_button{
key = "blinkon";
width = 2;
aspect_ratio = 2.5;
}
}
:row{
:text{
label = "Blink Off Color";
}
:image_button{
key = "blinkoff";
width = 2;
aspect_ratio = 2.5;
}
}
}
:boxed_column{
label = "Blinking Speed";
spacer_0;
:edit_box{
label = "Blinking Speed (sec):";
key = "blinker";
width = 2;
fixed_width = true;
}
spacer_1;
}
:boxed_row{
label = "Message...";
:text{
key = "message";
height = 3;
}
}
:row{
ok_cancel;
}
}
hl.ini
Configuration File for Highlight Layer Lisp
Highlight Layer v1.1
Blink On
41
Blink Off
161
Blink Speed
0.25