-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathSYSTEM.lsp
executable file
·182 lines (135 loc) · 5.6 KB
/
SYSTEM.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
;;;;;;;[ Resetting System Variables ];;;;;;;;;;;
;; ;;
;; All functions needed to save and restore ;;
;; AutoCAD system variables. Built on a hash. ;;
;; (requires HASH) ;;
;; ;;
;;::::::::::::::::::::::::::::::::::::::::::::::;;
;; ;;
;; Author: J.D. Sandifer (Copyright 2016) ;;
;; Written: 02/04/2016 ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; 04/13/2016 ;;
;; - Added LM:startundo, endundo (inc. acdoc) ;;
;; and endfile. ;;
;; - Shortened filename to SYSTEM. ;;
;; ;;
;; 03/22/2016 ;;
;; - Small edit - newline in text output for ;;
;; reset function. ;;
;; ;;
;; 03/15/2016 ;;
;; - Added ChangeVar(iable). ;;
;; - Added Save&ChangeVar. ;;
;; ;;
;; 02/04/2016 ;;
;; - Added SaveVar(iable). ;;
;; - Added ClearVar(iable)s. ;;
;; - Added ResetVar(iable). ;;
;; - Added ResetAllVar(iable)s. ;;
;; - Did preliminary testing. ;;
;; ;;
;; Todo: ;;
;; - Success messages or return values? ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; JD:ClearVar(iable)s - Copyright 2016 J.D. Sandifer
;;; Clears the list of system variables.
;;; variableList [symbol] - name of variable list to clear (nil value ok)
(defun JD:ClearVars (variableList /)
(JD:ClearHash variableList)
(princ))
;;; JD:SaveVar(iable) - Copyright 2016 J.D. Sandifer
;;; Saves the selected system variable if not already saved.
;;; variable [string] - system variable to store
;;; variableList [symbol] - name of the variable list to use
(defun JD:SaveVar (variable variableList /)
(setq variable (strcase variable T))
(if (not (JD:GetHash variable variableList))
(JD:PutHash variable (getvar variable) variableList))
(princ))
;;; JD:ChangeVar(iable) - Copyright 2016 J.D. Sandifer
;;; Changes the selected system variable.
;;; variable [string] - system variable to store
;;; newValue [varies] - the value to which to set the variable
(defun JD:ChangeVar (variable newValue /)
(setq variable (strcase variable T))
(setvar variable newValue)
(princ))
;;; JD:Save&ChangeVar(iable) - Copyright 2016 J.D. Sandifer
;;; Saves and changes the selected system variable.
;;; variable [string] - system variable to store
;;; variableList [symbol] - name of the variable list to use
;;; newValue [varies] - the value to which to set the variable
(defun JD:Save&ChangeVar (variable variableList newValue /)
(JD:SaveVar variable variableList)
(JD:ChangeVar variable newValue)
(princ))
;;; JD:ResetVar(iable)s - Copyright 2016 J.D. Sandifer
;;; Restores a single system variable from the list (without removing it).
;;; variable [string] - system variable to store
;;; variableList [symbol] - name of the variable list to use
(defun JD:ResetVar (variable variableList / oldValue didSucceed)
(setq variable (strcase variable T))
(cond
((setq oldValue (JD:GetHash variable variableList))
(setvar variable oldValue)
(setq didSucceed T))
(T
(setq didSucceed nil)))
didSucceed)
;;; JD:ResetAllVar(iable)s - Copyright 2016 J.D. Sandifer
;;; Restores all system variables in the list.
;;; variable [string] - system variable to store
;;; variableList [symbol] - name of the variable list to use (nil value ok)
(defun JD:ResetAllVars (variableList /)
(foreach
variablePair (eval variableList)
(JD:ResetVar (car variablePair) variableList))
(JD:ClearVars variableList)
(princ))
;;; Error handling function - prints error message nicely and resets system variables
(defun ErrorHandler (errorMessage)
(if (not (member
errorMessage
'("Function cancelled" "quit / exit abort")))
(princ (strcat "\nThere's a slight problem: " errorMessage)))
(JD:Save&ChangeVar "cmdecho" 'systemVariables 0)
(command-s "._UNDO" "_End") ; End UNDO group
(JD:ResetAllVars 'systemVariables)
(princ))
;; Start Undo - Lee Mac
;; Opens an Undo Group.
(defun
LM:startundo (doc)
(LM:endundo doc)
(vla-startundomark doc))
;; End Undo - Lee Mac
;; Closes an Undo Group.
(defun
LM:endundo (doc)
(while (= 8 (logand 8 (getvar 'undoctl)))
(vla-endundomark doc)))
;; Active Document - Lee Mac
;; Returns the VLA Active Document Object
(defun LM:acdoc nil
(eval
(list
'defun
'LM:acdoc
'nil
(vla-get-activedocument (vlax-get-acad-object))))
(LM:acdoc))
;;----------------------------------------------------------------------;;
(vl-load-com)
(princ
(strcat
"\n:: SYSTEM.lsp loaded. | \\U+00A9 J.D. Sandifer "
(menucmd "m=$(edtime,0,yyyy)")
" ::"))
(princ)
;;----------------------------------------------------------------------;;
;; End of File ;;
;;----------------------------------------------------------------------;;