- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We are using a routine that works well, if you run the routine from start to finish. If you have to hit the "escape" button to exit out of the routine, it will crash on you. The layers will not revert and for some reason, the osnap setting will reset to "0" layer. From what I have read, the error code I have written should reset all local variables to the start of the program. Could someone look at it and tell me how to fix it? I already know I need to stop using a donut command and use a block instead, but have not had the time to update.
;; This program installs a strut brace
;;; on the proper layers. If no layer
;;; exists, this program will create them.
;;;
;;; Program written by Kenneth Underhill
;;; Completed on December 17, 2008
;;; Revised April 12, 2018
;;;-------------------------------------------Program------------------------------------------------------------------------
(defun c:bc()
(setq temperr *error*) ; saves *error*
(setq *error* bcerr) ; sets the new error variable
(command "_.undo" "_mark") ; Starts the *undo* command
(graphscr)
(setq oldos (getvar "osmode")) ; Saves the current osnap setting
(setvar "osmode" 545) ; Sets the new osnap setting
(setq oldor (getvar "orthomode")) ; Saves the current ortho setting
(setvar "orthomode" 0) ; Turns off the ortho
(setq oldlayer (getvar "clayer")) ; Saves the current layer
(setq oldsc (getvar "selectioncycling"))
(setvar "selectioncycling" 0)
(command "_.layer" "_make" "STRUT" "_color" "1" "" "_ltype"
"continuous" "" "") ; Changes layer to Strut
(setq pt1(getpoint "\nSelect Brace Start Point: ")) ; Select brace starting point
(command "_.donut" "7" "9" pt1 "") ; Draws brace
(command "_.layer" "_make" "STRUT_LEG" "_color" "120" "" "_ltype"
"dashed2" "" "") ; Changes layer to Strut leg
(setvar "osmode" 0) ; turns osmode off
(setq pt2(getpoint "\nSelect Brace End Point: ")) ; Select brace end point
(setq don(entget(entlast))) ; selects the brace
(setq do(cdr(assoc 10 don))) ; finds the center of the brace
(command "_.line" pt2 "tan" do "" "_.mirror" "_last" "" pt2 "per" do "") ; Draws brace line to brace tangent and then mirrors it
(setvar "osmode" oldos) ; Sets the osnap to original settings
(setvar "orthomode" oldor) ; Sets the Ortho to original settings
(setvar "clayer" oldlayer) ; Sets the layer to original layer
(setq *error* bcerr) ; restores original error
(command "_.undo" "end") ; Ends the *undo* command
(princ)
) ; End Brace
;;;----------------------------ERROR-----------------------------------------------------------------------------
(defun bcerr (errmsg) ; defines error
(command "_.undo" "_back") ; removes any work done under this command
(setvar "osmode" oldos) ; sets the osnaps to previous settings
(setvar "orthomode" oldor) ; restores the ortho to previous setting
(setvar "clayer" oldlayer) ; sets the current layer to previous setting
(setvar "selectioncycling" oldsc)
(setq *error* bcerr) ; restores original error
(prompt "\nResetting System Variables ") ; prompts user
(princ)
) ; end error
Solved! Go to Solution.