Isaac26a Posted March 19, 2021 Share Posted March 19, 2021 1 hour ago, G Prameela said: I am looking for prefixing 'C' in front of a column layer which is shown only in integers. Example instead of C1, they have mentioned 1, due to some reason I wanted prefix C IN front of all these integers. Althought this shouldn't be in this post, I think this can solve your needs. ;;;;;;;;;;;; Program to put a prefix to all the layers except by 0 and Defpoints. ;;;;;;;;;;;; By Isaac Alcántara 20210319 ;;;;;;;;;;;; (vl-load-com) (defun c:preflay ( / lay lst lyn new prefix) (setvar "cmdecho" 0) (vl-cmdf "_.undo" "_begin") (setq prefix (getstring T "\nType the prefix to add to the layers: ")) (while (setq lay (tblnext "LAYER" (null lay))) (or (wcmatch (setq lyn (cdr (assoc 2 lay))) "0,Defpoints") (or (tblsearch "LAYER" (setq new (strcat prefix lyn))) (entmod (subst (cons 2 new) (assoc 2 (setq lst (entget (tblobjname "LAYER" lyn)))) lst)) ) ) ) (vl-cmdf "_.undo" "_end") (princ) ) Quote Link to comment Share on other sites More sharing options...
mickeforsberg Posted January 14, 2022 Share Posted January 14, 2022 (edited) Does this also work with multileaders or does that require a completely different approach? Edited January 14, 2022 by mickeforsberg Quote Link to comment Share on other sites More sharing options...
Isaac26a Posted January 15, 2022 Share Posted January 15, 2022 20 hours ago, mickeforsberg said: Does this also work with multileaders or does that require a completely different approach? I guess this can help you with what you are looking for (defun c:test ( ) (pstext (getstring t "\nSpecify Prefix <none>: ") (getstring t "\nSpecify Suffix <none>: ") 1) ) ;; (pstext "Prefix Text" "Suffix Text" <mode>) ;; ;; <mode> = 0 - single selection ;; = 1 - window selection ;; ;; Author: Lee Mac 2011 - www.lee-mac.com (defun pstext ( preftext sufftext mode / a e i s ) (cond ( (= 0 mode) (while (progn (setvar 'ERRNO 0) (setq e (car (nentsel))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, try again.") ) ( (eq 'ENAME (type e)) (if (wcmatch (cdr (assoc 0 (entget e))) "TEXT,MTEXT,ATTRIB,*LEADER,*DIMENSION") (entmod (setq e (entget e) a (assoc 1 e) e (subst (cons 1 (strcat preftext (cdr a) sufftext)) a e) ) ) (princ "\nInvalid Object.") ) ) ) ) ) ) ( (setq s (ssget "_:L" (list '(0 . "TEXT,MTEXT,ATTRIB,*LEADER,*DIMENSION")))) (repeat (setq i (sslength s)) (entmod (setq e (entget (ssname s (setq i (1- i)))) a (assoc 1 e) e (subst (cons 1 (strcat preftext (cdr a) sufftext)) a e) ) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
tombu Posted January 15, 2022 Share Posted January 15, 2022 "APTXT" from Cadalyst is a dialog based routine that allows you to add prefixes or suffixes to any text with many options. DDAPTXT.LSP Append to Text (c)June 1999, Scott A. Matthews added support for MTEXT & DIMENSION's March 2003, Tom Beauford https://forums.augi.com/showthread.php?6364-Text-prefix-suffix&p=37577&viewfull=1#post37577 Quote Link to comment Share on other sites More sharing options...
mickeforsberg Posted March 2, 2022 Share Posted March 2, 2022 (edited) On 1/15/2022 at 6:37 AM, Isaac26a said: I guess this can help you with what you are looking for Thanks! Sorry I haven't gotten back, I haven't had the chance to try it until now. I get an "error: bad argument type: stringp nil" Any idea? (it works with text still, but not multileaders) Edited March 2, 2022 by mickeforsberg Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.