-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_CustomShortcuts.lsp
305 lines (280 loc) · 8.41 KB
/
_CustomShortcuts.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
;good samples of common routines i would use
;https://github.com/dtgoitia/civil-autolisp/commits?author=dtgoitia
; UNDEFINE
;(command
; "_.undefine" "intersect"
; "_.undefine" "interfere"
; "_.undefine" "redraw"
; "_.undefine" "redrawall"
; "_.undefine" "fill"
; "_.undefine" "filletedge"
; "_.undefine" "surffillet"
; "_.undefine" "donut"
; "_.undefine" "donutid"
; "_.undefine" "donutod"
; "_.undefine" "targetpoint"
;)
(defun c:iso() (command "_.isolateobjects")(princ))
(defun c:iso() (command "_.isolateobjects")(princ))
(defun c:uiso() (command "_.unisolateobjects")(princ))
(defun c:c ( / ent_name )
; Fast copy
(if (ssget "_I")
(command "_.copy" "_non" (cadr (grread 't)) "_non" pause)
(if (setq ent_name (car (entsel "\nSelect object: ")))
(command "_.copy" ent_name "" "_non" (cadr (grread 't)) "_non" pause)
);END if
);END if
(princ)
; v0.2 - 2017.06.07 - Silent exit added
; v0.1 - 2017.06.01 - Previously selected entities considered
; - Nul selection considered
; v0.0 - 2017.??.?? - First issue
; Author: David Torralba
; Last revision: 2017.06.07
)
(defun c:cc() (command "_.copy") )
(defun c:m ( / ent_name )
; Fast copy
(if (ssget "_I")
(command "_.move" "_non" (cadr (grread 't)) "_non" pause)
(if (setq ent_name (car (entsel "\nSelect object: ")))
(command "_.move" ent_name "" "_non" (cadr (grread 't)) "_non" pause)
);END if
);END if
(princ)
; v0.0 - 2017.06.07 - First issue
; Author: David Torralba
; Last revision: 2017.06.07
)
;(defun c:m() (command "_.move" pause "" "_non" (cadr (grread 't)) "_non" pause) )
(defun c:mo() (command "_.move"))
(defun c:mm() (command "_.move"))
(defun c:p00()
(command
"_.pasteblock" "0,0"
"_.scale" "L" "" "0,0" "1000"
"_.explode" "L" ""
"_.zoom" "O" "L" ""
)
(princ)
)
(defun c:ci() (command "_.circle")(princ))
(defun c:n() (command "_.NCOPY" pause "" "" ""))
(defun c:xr ()
; Open and close External Reference pannel
(if (= 0 (getvar "ERState"))
; Open External Reference pannel
(command "ExternalReferences")
; Close External Reference pannel
(command "ExternalReferencesClose")
);END if
(princ)
; v0.0 - 2017.06.28 - First issue
; Author: David Torralba
; Last revision: 2017.06.28
)
(defun c:t () (command "_.textedit" "M" "S" pause))
(defun c:pp()(command "_.publish"))
(defun c:las() (command "_.layerstate")(princ))
(defun c:zz ( / ss )
; Change selected entities' color to blue
(princ "\nMarking in blue:")
(if (setq ss (ssget))
(foreach a (ssnamex ss)
(if (= 'ename (type (cadr a)))
(vlax-put-property (vlax-ename->vla-object (cadr a)) 'Color 5)
);END if
);END foreach
);END if
; v0.0 - 2017.03.13 - First issue
; Author: David Torralba
; Last revision: 2017.03.13
)
(defun c:o ( / x ) (if (setq x (getint (strcat "\nObject Snap Mode <" (itoa (getvar "osmode")) ">: "))) (setvar "osmode" x) (princ "*Cancel*"))(princ))
(defun c:os () (c:o))
(defun c:rr () (princ "\nMultiple rotate:") (c:RTM))
(defun c:rrr() (princ "\nRegenerating...") (command "_.regenall") (princ " done.")(princ))
(defun c:nt( / oldtextstyle olderror pt)
(save_environment (list "textstyle" "cmdecho"))
(setvar "cmdecho" 0)
(setq
pt (getpoint "\nSelect text insertion point: ")
)
(command
"-text" "S"
(if (tblsearch "STYLE" "ARIAL") "ARIAL" "Standard") ; Text style management
"J" "MC" pt 3
(* (if (= 1 (getvar "angdir")) 1 -1) (getvar "angbase") (/ 180 pi) ) ; Text rotation management
(getstring t "\nEnter text: ")
"scale" "L" "" pt pause
)
; RESTORE SETTINGS
(restore_environment)
(princ)
; V0.1 - 2017.05.12 - Error management implemented
; v0.0 - 2016.??.?? - First issue
; Author: David Torralba
; Last revision: 2017.05.12
)
(defun c:ha ( )
; automatic HAtching
; This function selects the polylines within the selection set,
; closes them and creates an individual associative hatch for each polyline
;
(vl-load-com)
(foreach a (ssnamex (ssget '((-4 . "<OR") (0 . "LWPOLYLINE") (0 . "POLYLINE") (-4 . "OR>"))) )
(if (= 'ename (type (cadr a)))
(DT:ha (cadr a) "ANSI31" "0.1")
);END if
);END foreach
; v0.2 - 2016.12.23 - DT:ha implemented
; v0.1 - 2016.06.15 - Force hatch to be in current layer.
; v0.0 - 2016.03.16 - First issue
; Author: David Torralba
; Last revision: 2016.12.23
)
(defun c:has()
(command "-hatch" "S" (ssget) "" "")
(princ)
; v0.0 - 2017.??.?? - First issue
; Author: David Torralba
; Last revision: 2017.05.12
)
(defun c:BYR ( / ss)
; Set by layer recursive
(princ "\nSet ByLayer recursive: ")
(setq ss (ssget))
(command "._SetByLayer" ss "" "y" "y")
; v0.1 - 2017.05.15 - Command renamed to BYR
; v0.0 - 2016.03.18 - First issue
; Author: David Torralba
; Last revision: 2016.03.18
)
(defun c:BY ()
; Shortcut to c:BYC
; NOTE: old c:BY command renamed to BYR (BYlayer Recursive)
(c:BYC)
; v0.0 - 2017.05.15 - First issue
; Author: David Torralba
; Last revision: 2017.05.15
)
(defun c:BYC ( / ss )
(princ "\nSelet objects to set ByLayer:")
(if (setq ss (ssget))
(foreach a (ssnamex ss)
(if (= 'ename (type (cadr a)))
(vlax-put-property (vlax-ename->vla-object (cadr a)) 'Color 256)
);END if1
);END foreach
);END if
(princ)
; v0.3 - 2017.05.15 - ss=nil case management
; v0.2 - 2017.03.14 - Xref' filter removed, pointless
; v0.1 - 2016.11.14 - Xref's filtered and excluded to speed up command
; v0.0 - 2016.11.11 - First issue
; Author: David Torralba
; Last revision: 2017.05.15
)
(defun c:c0()
; Shortcut for copybase with origin (0 0 0) as reference coordinates
(command "copybase" (list 0 0 0) (ssget) "")(princ)
)
(defun c:p0()
; Shortcut to PASTECLIP at origin (0 0 0)
(command "_pasteclip" "0,0")(princ)
)
(defun c:au ()
; Fast audit and save
(command "audit" "Yes")
(command "_qsave")
(princ "\nDrawing audited and saved.")
(alert "Drawing audited and saved.")
(princ)
; v0.0 - 2016.03.18 - First issue
; Author: David Torralba
; Last revision: 2016.03.18
)
(defun c:s()
; Save and prompt message
(command "_qsave")
(princ "\nDrawing saved.")
(alert "Drawing saved.")
(princ)
; v0.0 - 2016.11.17 - First issue
; Author: David Torralba
; Last revision: 2016.11.17
)
(defun c:cl ( / ss i ent ent_name VL_ent_name)
; Close selected polylines
(if (setq ss (ssget '((-4 . "<OR")(0 . "LWPOLYLINE")(0 . "POLYLINE")(-4 . "OR>"))))
(foreach a (ssnamex ss)
(if (= 'ename (type (cadr a)))
(if (= :vlax-false (vla-get-closed (vlax-ename->vla-object (cadr a))))
(vla-put-closed (vlax-ename->vla-object (cadr a)) :vlax-true)
);END if
);END if
);END foreach
);END if
(princ)
; v0.1 - 2017.05.12 - Code rewritten and commented
; v0.0 - 2016.03.16 - First issue
; Author: David Torralba
; Last revision: 2017.05.12
)
(defun c:dump ( / object )
; Print object methods and attributes
(if (setq ent_name (car (entsel "\nSelect object to see methods and properties: ")) )
(vlax-dump-object (vlax-ename->vla-object ent_name))
);END if
(princ)
; v0.0 - 2017.05.12 - First issue
; Author: David Torralba
; Last revision: 2017.05.12
)
(defun c:entget ( / ent_name )
; Print entity definition data
(if (setq ent_name (car (entsel "\nSelect entity to see definition data: ")) )
(progn
(princ "\n")
(princ (entget ent_name))
);END progn
);END if
(princ)
; v0.0 - 2017.06.23 - First issue
; Author: David Torralba
; Last revision: 2017.06.23
)
(defun c:EntDef ( / ent_name el1 lel1 el2 )
; Print entity definition data in a table
(if (setq ent_name (car (entsel "\nSelect entity to see definition data: ")) )
(if
(setq tableList
(mapcar
'(lambda (x) (list (car x) (cdr x) (type (cdr x)) ) )
(entget ent_name)
);END mapcar
)
(princ (DT:ListToTable (DT:StringifyTableList tableList)))
);END if
);END if
(princ)
; v0.0 - 2017.06.23 - First issue
; Author: David Torralba
; Last revision: 2017.06.23
)
(defun c:v1 () (command "-vports" "si") )
(defun c:v2 () (command "-vports" "2" "v") )
(defun c:la ()
; Open and close Layer Manager pannel
(if (= 0 (getvar "LayerManagerState"))
; Open Layer Manager pannel
(command "LayerPalette")
; Close Layer Manager pannel
(command "LayerClose")
);END if
(princ)
; v0.0 - 2017.06.07 - First issue
; Author: David Torralba
; Last revision: 2017.06.07
)