K Baden Posted June 7, 2019 Posted June 7, 2019 (edited) Good morning! I am hoping someone has something laying around that can help. I need a specific incremental text that is pretty simple. I basically would like for something at does the following on each click: A1 A2 A3 etc.. but i want to be able to key in something while using to reset the number increment and change the letter to the next letter like so: A1 A2 A3 (*some sort of way to indicate i am ready to reset the number and increment the letter here*) B1 B2 B3 (*some sort of way to indicate i am ready to reset the number and increment the letter here*) C1 C2 C3 etc.. I know Lee MAc has the awesome numbering suite and I have attempted to try and grab pieces of it... but my LISP skills are way too rusty for that to have any success. I really just want something much smaller to accomplish this as this is the only incremental thing i will ever need to do. Does anyone have any idea how i would accomplish this? (PS, the text style will be ROMANS and a text height of 3/32" on layer TEXT, if that makes any difference) Thanks in advance for any help!!! Edited June 7, 2019 by K Baden Quote
Lee Mac Posted June 7, 2019 Posted June 7, 2019 Here is a very basic example: (defun c:inc ( / *error* alp ang hgt ins lay num ocs sty ) (defun *error* ( msg ) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (setq sty (getvar 'textstyle) ;; Text Style hgt (getvar 'textsize) ;; Text Height lay (getvar 'clayer) ;; Text Layer ocs (trans '(0 0 1) 1 0 t) ang (angle '(0 0) (trans (getvar 'ucsxdir) 0 ocs t)) ) (if (not inc:alp) (setq inc:alp "A")) (if (not inc:num) (setq inc:num 1)) (if (not (tblsearch "style" sty)) (setq sty (getvar 'textstyle))) (while (not (or (= "" (setq alp (strcase (getstring (strcat "\nSpecify alpha prefix <" inc:alp ">: "))))) (wcmatch alp "~*[~A-Z]*") ) ) (princ "\nPrefix may only contain the characters A-Z.") ) (if (= "" alp) (setq alp inc:alp) (setq inc:alp alp) ) (initget 4) (if (setq num (getint (strcat "\nSpecify numerical suffix <" (itoa inc:num) ">: "))) (setq inc:num num) (setq num inc:num) ) (while (progn (initget "Prefix Suffix") (setq ins (getpoint (strcat "\rSpecify point for " alp (itoa num) " [Prefix/Suffix] <exit>: "))) ) (cond ( (= "Prefix" ins) (setq alp (LM:alpha++ alp) num 1)) ( (= "Suffix" ins) (setq num (1+ num))) ( (entmake (list '(000 . "TEXT") (cons 008 lay) (cons 007 sty) (cons 040 hgt) (cons 050 ang) (cons 010 (trans ins 1 ocs)) (cons 001 (strcat alp (itoa num))) (cons 210 ocs) ) ) (setq num (1+ num)) ) ) ) (princ) ) ;; Alpha++ - Lee Mac ;; Increments an uppercase alphabetical string by one, e.g. AZ => BA ;; a - [str] uppercase alphabetical string (defun LM:alpha++ ( a / n ) (if (= "" a) "A" (if (= "Z" (substr a (setq n (strlen a)))) (strcat (LM:alpha++ (substr a 1 (1- n))) "A") (strcat (substr a 1 (1- n)) (chr (1+ (ascii (substr a n))))) ) ) ) (princ) Quote
K Baden Posted June 10, 2019 Author Posted June 10, 2019 This is perfect! Thank you so much for the help. One additional question, can i change it to MTEXT jsut by updating it in the code to MTEXT here? '(000 . "TEXT") And are any of these properties able to update th justification to middle Center? if not, how would i add that into the specifications of properties? Thank you again!!! Quote
Lee Mac Posted June 10, 2019 Posted June 10, 2019 2 hours ago, K Baden said: This is perfect! Thank you so much for the help. You're welcome. 2 hours ago, K Baden said: One additional question, can i change it to MTEXT jsut by updating it in the code to MTEXT here? '(000 . "TEXT") No, MTEXT DXF data requires you to specify the sub class markers AcDbEntity & AcDbMText (DXF group 100). 2 hours ago, K Baden said: And are any of these properties able to update th justification to middle Center? if not, how would i add that into the specifications of properties? Yes - for TEXT the justification is represented using DXF groups 72 & 73; for MTEXT, it is represented using DXF group 71. Therefore, for middle-center justified MText, replace the first entry in the DXF data: '(000 . "TEXT") With: '(000 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") '(071 . 5) Quote
K Baden Posted June 11, 2019 Author Posted June 11, 2019 This is perfect. thank you so much, Lee! Quote
Lee Mac Posted June 11, 2019 Posted June 11, 2019 1 hour ago, K Baden said: This is perfect. thank you so much, Lee! You're welcome! Quote
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.