leonucadomi Posted March 7 Posted March 7 hello all: I need a routine that first asks me to enter "a word" and this word is added to the value of the dimension below the line example The modified dimension shows this Does anyone know of any code that can help me? thanks Quote
Lee Mac Posted March 7 Posted March 7 Here's a quick one - (defun c:dimsub ( / enx grp idx new pos sel str ) (cond ( (= "" (setq str (getstring t "\nSpecify string: ")))) ( (setq sel (ssget "_:L" '((0 . "*DIMENSION")))) (repeat (setq idx (sslength sel)) (setq idx (1- idx) enx (entget (ssname sel idx)) grp (assoc 1 enx) ) (if (setq pos (vl-string-search "\\X" (cdr grp))) (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str))) (setq new (cons 1 (strcat "<>\\X" str))) ) (entmod (subst new grp enx)) ) ) ) (princ) ) 1 Quote
leonucadomi Posted March 7 Author Posted March 7 7 minutes ago, Lee Mac said: Here's a quick one - (defun c:dimsub ( / enx grp idx new pos sel str ) (cond ( (= "" (setq str (getstring t "\nSpecify string: ")))) ( (setq sel (ssget "_:L" '((0 . "*DIMENSION")))) (repeat (setq idx (sslength sel)) (setq idx (1- idx) enx (entget (ssname sel idx)) grp (assoc 1 enx) ) (if (setq pos (vl-string-search "\\X" (cdr grp))) (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str))) (setq new (cons 1 (strcat "<>\\X" str))) ) (entmod (subst new grp enx)) ) ) ) (princ) ) i will try master thanks Quote
leonucadomi Posted March 7 Author Posted March 7 EXCELLENT... You can make it so that by default it suggests the word "typ" so that with just one enter I can continue the routine and if in the future I need to add another word I can change it. Quote
Lee Mac Posted March 7 Posted March 7 36 minutes ago, leonucadomi said: You can make it so that by default it suggests the word "typ" so that with just one enter I can continue the routine and if in the future I need to add another word I can change it. For a "fixed" default, you can use something like the following: (defun c:dimsub ( / enx grp idx new pos sel str ) (if (= "" (setq str (getstring t "\nSpecify string <TYP>: "))) (setq str "TYP") ) (if (setq sel (ssget "_:L" '((0 . "*DIMENSION")))) (repeat (setq idx (sslength sel)) (setq idx (1- idx) enx (entget (ssname sel idx)) grp (assoc 1 enx) ) (if (setq pos (vl-string-search "\\X" (cdr grp))) (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str))) (setq new (cons 1 (strcat "<>\\X" str))) ) (entmod (subst new grp enx)) ) ) (princ) ) For a "dynamic" default, you can use one of the methods I describe here. 1 Quote
BIGAL Posted March 8 Posted March 8 Interesting ""Windows Speech Recognition," and then use the shortcut Windows logo key + Ctrl + S to activate it. Typed dimsub then spoke T Y P a box appeared then did accept. !typ = "TYP " very close. It did 1st go put EYP in command line. So I think I need to train it more. Can turn on and off microphone by voice. If I have time may play more. 1 Quote
leonucadomi Posted 5 hours ago Author Posted 5 hours ago On 3/7/2025 at 5:58 PM, Lee Mac said: For a "fixed" default, you can use something like the following: (defun c:dimsub ( / enx grp idx new pos sel str ) (if (= "" (setq str (getstring t "\nSpecify string <TYP>: "))) (setq str "TYP") ) (if (setq sel (ssget "_:L" '((0 . "*DIMENSION")))) (repeat (setq idx (sslength sel)) (setq idx (1- idx) enx (entget (ssname sel idx)) grp (assoc 1 enx) ) (if (setq pos (vl-string-search "\\X" (cdr grp))) (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str))) (setq new (cons 1 (strcat "<>\\X" str))) ) (entmod (subst new grp enx)) ) ) (princ) ) For a "dynamic" default, you can use one of the methods I describe here. master , I am trying to do the following (defun c:dimsub ( / enx grp idx new pos sel str ) (princ "\nColoca subfijo a dimension por debajo de linea con opcion de cambio") ; (if (= "" (setq str (getstring t "\nSpecify string <TYP>: "))) ;(setq str "TYP") ; ) (if (setq sel (ssget "_:L" '((0 . "*DIMENSION")))) (repeat (setq idx (sslength sel)) (setq idx (1- idx) enx (entget (ssname sel idx)) grp (assoc 1 enx) ) (if (setq pos (vl-string-search "\\X" (cdr grp))) (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str))) (setq new (cons 1 (strcat "+" "<>\\X" "TEXT 1"))) ) (entmod (subst new grp enx)) ) ) (princ) ) Quote
leonucadomi Posted 5 hours ago Author Posted 5 hours ago I NEED TO ADD A SECOND TEXT BELOW THE FIRST Quote
GLAVCVS Posted 2 hours ago Posted 2 hours ago (edited) Another option (defun c:subTexta (/ e le txa tx cj para) (if (/= (setq tx (getstring "\nType TEXT to add?: ")) "") (while (setq n (not (setvar "NOMUTT" 1)) x (princ (strcat "\rAdd \'" tx "\' to DIMENSIONs...")) cj (ssget "_:L" '((0 . "*DIMENSION")))) (while (setq e (ssname cj (setq n (if n (1+ n) 0)))) (entmod (subst (cons 1 (cond ((or (wcmatch (setq txa (cdr (assoc 1 (setq le (entget e))))) "*<>\n*") (wcmatch txa "*<>\\X*")) (strcat txa "\n" tx)) (T (strcat txa "<>\\X" tx)))) (assoc 1 le) le ) ) ) ) ) (setvar "NOMUTT" 0) (princ) ) Edited 2 hours ago by GLAVCVS 1 Quote
GLAVCVS Posted 2 hours ago Posted 2 hours ago (edited) 2 minutes ago, GLAVCVS said: Another option (defun c:subTexta (/ e le txa tx cj para) (if (/= (setq tx (getstring "\nType TEXT to add?: ")) "") (while (setq n (not (setvar "NOMUTT" 1)) x (princ (strcat "\rAdd \'" tx "\' to DIMENSIONs...")) cj (ssget "_:L" '((0 . "*DIMENSION")))) (while (setq e (ssname cj (setq n (if n (1+ n) (setvar "NOMUTT" 0))))) (entmod (subst (cons 1 (cond ((or (wcmatch (setq txa (cdr (assoc 1 (setq le (entget e))))) "*<>\n*") (wcmatch txa "*<>\\X*")) (strcat txa "\n" tx)) (T (strcat txa "<>\\X" tx)))) (assoc 1 le) le ) ) ) ) ) (princ) ) To add all the text lines you need Edited 2 hours ago by GLAVCVS 1 Quote
GLAVCVS Posted 2 hours ago Posted 2 hours ago @leonucadomi You should copy the code again. I changed a small thing to prevent NOMUTT from staying at 1. 1 Quote
leonucadomi Posted 1 hour ago Author Posted 1 hour ago @GLAVCVS IT'S OKAY, I JUST NEED IT WITHOUT HAVING TO ADD THE TEXT TO THE BEGINNING, SO TEXTS 1 AND 2 WILL ALREADY BE DEFINED WITHIN THE ROUTINE I mean I just select a dimension and the result is... true dimension accompanied by the "+" sign and below the line "text 1" and below this "text 2" (defun c:dimsub ( / enx grp idx new pos sel str ) (princ "\nColoca subfijo a dimension por debajo de linea con opcion de cambio") (if (setq sel (ssget "_:L" '((0 . "*DIMENSION")))) (repeat (setq idx (sslength sel)) (setq idx (1- idx) enx (entget (ssname sel idx)) grp (assoc 1 enx) ) (if (setq pos (vl-string-search "\\X" (cdr grp))) (setq new (cons 1 (strcat (substr (cdr grp) 1 pos) "\\X" str))) (setq new (cons 1 (strcat "+" "<>\\X" "TEXT 1))) ) (entmod (subst new grp enx)) ) ) (princ) ) this routine is from the master @Lee Mac I mean I'm looking to add a second line Quote
GLAVCVS Posted 1 minute ago Posted 1 minute ago I think the best way to explain it is to include a picture of the vote before and after it was modified. Although perhaps other, more awake minds than mine have already understood it. 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.