Hi all,
I have this Lisp routine that I took from this site previously, but would like a modification made. I'm hoping somebody could possibly help me out.
So, the below routine simply adds a comma as a suffix to text. However, I would like it to now be added as a prefix.
(defun c:addcomma (/ olderr e sm)
(setq olderr *error*)
(defun *error* (msg)
(if (/= msg "Function cancelled")
(prompt (strcat "\nError: " msg))
)
(setvar "SNAPMODE" sm)
(setq *error* olderr) ;Restore old *error* handler
(princ)
)
(setq sm (getvar "SNAPMODE"))
(setvar "SNAPMODE" 0)
(while (setq e (car (nentsel "\nLocate text to add comma: ")))
(if (member (strcase (cdr (assoc 0 (entget e)))) '("TEXT" "ATTRIB" "MTEXT"))
(entupd (cdr (assoc -1 (entmod (subst (cons 1 (strcat (cdr (assoc 1 (entget e))) ","))(assoc 1 (entget e))(entget e))))))
)
)
(setvar "SNAPMODE" sm)
(setq *error* olderr)
(princ)
)
Thanks in advance for any help given!
Brendon
Solved! Go to Solution.
Try the code modified from your post:
brendon.butler wrote:
Hi all,
I have this Lisp routine that I took from this site previously, but would like a modification made. I'm hoping somebody could possibly help me out.
So, the below routine simply adds a comma as a suffix to text. However, I would like it to now be added as a prefix.
(defun c:addcomma (/ olderr e sm)
(setq olderr *error*)
(defun *error* (msg)
(if (/= msg "Function cancelled")
(prompt (strcat "\nError: " msg))
)
(setvar "SNAPMODE" sm)
(setq *error* olderr) ;Restore old *error* handler
(princ)
)
(setq sm (getvar "SNAPMODE"))
(setvar "SNAPMODE" 0)
(while (setq e (car (nentsel "\nLocate text to add comma: ")))
(if (member (strcase (cdr (assoc 0 (entget e)))) '("TEXT" "ATTRIB" "MTEXT"))
(entupd (cdr (assoc -1 (entmod (subst (cons 1 (strcat (cdr "," (assoc 1 (entget e)))))(assoc 1 (entget e))(entget e))))))
)
)
(setvar "SNAPMODE" sm)
(setq *error* olderr)
(princ)
)
Thanks in advance for any help given!
Brendon
(defun c:addcomma (/ olderr e sm)
(setq olderr *error*)
(defun *error* (msg)
(if (/= msg "Function cancelled")
(prompt (strcat "\nError: " msg))
)
(setvar "SNAPMODE" sm)
(setq *error* olderr) ;Restore old *error* handler
(princ)
)
(setq sm (getvar "SNAPMODE"))
(setvar "SNAPMODE" 0)
(while (setq e (car (nentsel "\nLocate text to add comma: ")))
(if (member (strcase (cdr (assoc 0 (entget e)))) '("TEXT" "ATTRIB" "MTEXT"))
(entupd (cdr (assoc -1 (entmod (subst (cons 1 (strcat "," (cdr (assoc 1 (entget e)))))(assoc 1 (entget e))(entget e))))))
)
)
(setvar "SNAPMODE" sm)
(setq *error* olderr)
(princ)
)
Can't find what you're looking for? Ask the community or share your knowledge.