;================================================= ======================
; AddFix.Lsp Mar 14, 2000
; Add Either Suffix Or Prefix To Selected Strings
;================== Start Program ======================================
(princ "\nCopyright (C) 2000, Fabricated Designs, Inc.")
(princ "\nLoading AddFix v1.0 ")
(setq af_ nil lsp_file "AddFix")

;================== Macros =============================================
(defun PDot ()(princ "."))

(PDot);++++++++++++ Set Modes & Error ++++++++++++++++++++++++++++++++++
(defun af_smd ()
(SetUndo)
(setq olderr *error*
*error* (lambda (e)
(while (> (getvar "CMDACTIVE") 0)
(command))
(and (/= e "quit / exit abort")
(princ (strcat "\nError: *** " e " *** ")))
(and (= (logand (getvar "UNDOCTL") 8) 8)
(command "_.UNDO" "_END" "_.U"))
(af_rmd))
af_var '(("CMDECHO" . 0) ("MENUECHO" . 0)
("MENUCTL" . 0) ("MACROTRACE" . 0)
("OSMODE" . 0) ("SORTENTS" . 119)
("MODEMACRO" . ".")
("BLIPMODE" . 0) ("EXPERT" . 0)
("SNAPMODE" . 1)
("ORTHOMODE" . 1) ("GRIDMODE" . 0)
("ELEVATION" . 0) ("THICKNESS" . 0)
("FILEDIA" . 0) ("FILLMODE" . 0)
("SPLFRAME" . 0) ("UNITMODE" . 0)
("UCSICON" . 1)
("HIGHLIGHT" . 1) ("REGENMODE" . 1)
("COORDS" . 2) ("DRAGMODE" . 2)
("CECOLOR" . "BYLAYER")
("CELTYPE" . "BYLAYER")))
(foreach v af_var
(and (getvar (car v))
(setq af_rst (cons (cons (car v) (getvar (car v))) af_rst))
(setvar (car v) (cdr v))))
(princ (strcat (getvar "PLATFORM") " Release " (ver)
" - Add Text Prefix/Suffix ....\n"))
(princ))

(PDot);++++++++++++ Return Modes & Error +++++++++++++++++++++++++++++++
(defun af_rmd ()
(setq *error* olderr)
(foreach v af_rst (setvar (car v) (cdr v)))
(command "_.UNDO" "_END")
(prin1))

(PDot);++++++++++++ Set And Start An Undo Group ++++++++++++++++++++++++
(defun SetUndo ()
(and (zerop (getvar "UNDOCTL"))
(command "_.UNDO" "_ALL"))
(and (= (logand (getvar "UNDOCTL") 2) 2)
(command "_.UNDO" "_CONTROL" "_ALL"))
(and (= (logand (getvar "UNDOCTL") 8) 8)
(command "_.UNDO" "_END"))
(command "_.UNDO" "_GROUP"))

(PDot);************ Main Program ***************************************
(defun af_ (/ olderr af_var af_rst st ns ss i en ed tv)
(af_smd)

(initget 1 "Prefix Suffix")
(setq st (getkword "\nAdd Prefix/Suffix (P/S): "))

(setq ns (getstring t "\nNew String To Add: "))

(and (setq ss (ssget '((0 . "*TEXT"))))
(setq i (sslength ss))
(while (not (minusp (setq i (1- i))))
(setq en (ssname ss i)
ed (entget en)
tv (cdr (assoc 1 ed))
ed (subst
(cons 1 (if (= st "Suffix")
(strcat tv ns)
(strcat ns tv)))
(assoc 1 ed) ed))
(entmod ed)))

(af_rmd))

(PDot);************ Load Program ***************************************
(defun C:AF () (af_))
(if af_ (princ "\nAddFix Loaded\n"))
(prin1)
(c:af)

Advertisements