forked from JonathanHandojo/Sample-LISP-Routines-for-AutoCAD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrefixSuffixText.lsp
More file actions
58 lines (54 loc) · 3.23 KB
/
PrefixSuffixText.lsp
File metadata and controls
58 lines (54 loc) · 3.23 KB
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
;;; PrefixSuffixText.lsp ;;;
;;; Created by Jonathan Handojo ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
;;; This LISP routine allows the user to add a common prefix and suffix to a selected group ;;;
;;; of texts in unlocked layers. Upon issuing the command PRESUF, the user is prompted a ;;;
;;; selection of texts and mtexts, and then prompted for a prefix and suffix text to append to ;;;
;;; all the selected texts. ;;;
;;; ;;;
;;; How to use the PRESUF command: ;;;
;;; ;;;
;;; 1. Select a group of texts you wish to modify ;;;
;;; 2. Specify the prefix you want to append to the selected texts ;;;
;;; 3. Specify the suffix you want to append to the selected texts ;;;
;;; 4. Done ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:presuf (/ *error* acadobj activeundo adoc ent i msp prf ss suf txt)
(defun *error* ( msg )
(vla-EndUndoMark adoc)
(if (not (wcmatch (strcase msg T) "*break*,*cancel*,*exit*"))
(princ (strcat "Error: " msg))
)
)
(setq acadobj (vlax-get-acad-object)
adoc (vla-get-ActiveDocument acadobj)
msp (vla-get-ModelSpace adoc)
activeundo nil)
(if (= 0 (logand 8 (getvar "UNDOCTL"))) (vla-StartUndoMark adoc) (setq activeundo T))
(if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT"))))
(progn
(setq prf (getstring t "\nSpecify prefix to add: ")
suf (getstring t "\nSpecify suffix to add: ")
)
(if (not (and (eq prf "") (eq suf "")))
(repeat (setq i (sslength ss))
(setq ent (ssname ss (setq i (1- i)))
txt (assoc 1 (entget ent))
)
(entmod (subst (cons 1 (strcat prf (cdr txt) suf)) txt (entget ent)))
)
)
)
)
(if activeundo nil (vla-EndUndoMark adoc))
(princ)
)
(vl-load-com)