Zorg Posted May 11, 2009 Posted May 11, 2009 I've got a LISP for matching text and attributes but it doesn't work for MTEXT. Can anyone rectify it for me? It's in another language too, so i supose this doesn't help (defun UNDO-BEGIN () (command "UNDO" "BEGIN") ) (defun UNDO-EIND () (command "UNDO" "END") ) (defun ERRHAND (MSG) (if (/= MSG "Function cancelled") (progn (princ (strcat "\nFunction terminated" )) (setvar "SNAPMODE" OUDE-SNAP) (redraw) (setq *ERROR* OUDE-ERR) (UNDO-EIND) (princ) ) ) ) (defun ERR-BEGIN () (setvar "CMDECHO" 0) (setq OUDE-ERR *ERROR* *ERROR* ERRHAND ) ) (defun ERR-EIND () (setq *ERROR* OUDE-ERR) (princ) ) (defun C:MT ( / BRON_ENT ; bron-entiteit BRON_TEKST ; tekst van de bron-entiteit BRON_SEL ; selectiegegevens van bron-entiteit BRONPUNT ; beginpunt van aanduidingslijn DOEL_ENT ; doel-entiteit DOELPUNT ; selectiepunt van doel-entiteit LIJNTELLER ; teller die de zichtbaarheid van de aanduidingslijn regelt LIJNVLAG ; regelt het einde van de aanduidingslijn MATCHVLAG ; regelt het herhelen van doel-entiteit SURSORPUNT ; eindpunt van aanduidingslijn OUDE-SNAP ; snap-instelling OUDE-ERR ; error-instelling ) (ERR-BEGIN) (UNDO-BEGIN) (setq OUDE-SNAP (getvar "SNAPMODE")) (setvar "SNAPMODE" 0) (setq BRON_SEL (nentsel "\nSelect source text or attribute.") BRONPUNT (car (cdr BRON_SEL)) BRON_ENT (car BRON_SEL) LIJNTELLER 0 MATCHVLAG T ) (if (AND (/= (cdr (assoc 0 (entget BRON_ENT))) "ATTRIB") (/= (cdr (assoc 0 (entget BRON_ENT))) "TEXT")) (princ " Entity must be a text or attribute !") (progn (setq BRON_TEKST (cdr (assoc 1 (entget BRON_ENT)))) (while MATCHVLAG (setq CURSORPUNT nil LIJNVLAG T ) (princ "\n Select text or attribute to change. ") (while LIJNVLAG (setq CURSORPUNT (grread T 5 2)) (if (= 11 (car CURSORPUNT)) (progn (setq MATCHVLAG nil) (redraw) ) (setq MATCHVLAG T) ) (setq DOELPUNT (car (cdr CURSORPUNT))) (grdraw BRONPUNT DOELPUNT 7) ;7=wit (if (= (/ LIJNTELLER 3.0)(/ LIJNTELLER 3)) (redraw) ) (setq LIJNTELLER (+ LIJNTELLER 1)) (if (= LIJNTELLER 1000) (setq LIJNVLAG nil) ) (if (= 3 (car CURSORPUNT)) (progn (setq LIJNVLAG nil) (redraw) ) ) ) (if (= nil (setq DOEL_ENT (car (nentselp DOELPUNT)))) (princ " Nothing selected, retry !") (progn (if (AND (/= (cdr (assoc 0 (entget DOEL_ENT))) "ATTRIB") (/= (cdr (assoc 0 (entget DOEL_ENT))) "TEXT") ) (princ " No text or attribute selected, retry !") (progn (setq DOEL_ENT (entget DOEL_ENT)) (entmod (subst (cons 1 BRON_TEKST)(assoc 1 DOEL_ENT) DOEL_ENT )) (entupd (cdr (assoc -1 DOEL_ENT))) ) ) ) ) ) ) ) (setvar "SNAPMODE" OUDE-SNAP) (UNDO-EIND) (ERR-EIND) ) ; defun C:MATCHTXT Z Quote
Lee Mac Posted May 11, 2009 Posted May 11, 2009 Three options for you *Just thought I'd write my own versions...* Let me know which one you like best [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:mt [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] cEnt mEnt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Source Text: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"TEXT"[/color][/b] [b][color=#ff00ff]"MTEXT"[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]redraw[/color][/b] cEnt [b][color=#009900]3[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] mEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Destination Text: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"TEXT"[/color][/b] [b][color=#ff00ff]"MTEXT"[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entmod[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]subst[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]redraw[/color][/b] cEnt [b][color=#009900]4[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> Incorrect Selection <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:mt2 [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] cEnt mEnt sLst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Source Text: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"TEXT"[/color][/b] [b][color=#ff00ff]"MTEXT"[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]redraw[/color][/b] cEnt [b][color=#009900]3[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=#ff00ff]"_X"[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]-4[/color][/b] . [b][color=#ff00ff]"<NOT"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#ff00ff]"TEXT,MTEXT,INSERT"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=#009900]-4[/color][/b] . [b][color=#ff00ff]"NOT>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b]x[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]redraw[/color][/b] x [b][color=#009900]2[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] sLst [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]cadr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssnamex[/color][/b] ss[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] mEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Destination Text: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"TEXT"[/color][/b] [b][color=#ff00ff]"MTEXT"[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entmod[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]subst[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> Incorrect Selection <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_regenall"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:mt3 [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] cEnt ss[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Source Text: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"TEXT"[/color][/b] [b][color=#ff00ff]"MTEXT"[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]redraw[/color][/b] cEnt [b][color=#009900]3[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#ff00ff]"TEXT,MTEXT"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]foreach[/color][/b] x [b][color=RED]([/color][/b][b][color=BLUE]vl-remove-if[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]listp[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]cadr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssnamex[/color][/b] ss[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entmod[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]subst[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] x[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] x[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> Incorrect Selection <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_regenall"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] 1 Quote
Lee Mac Posted May 11, 2009 Posted May 11, 2009 Always there for me Lee ;D I just like to vary things a bit Quote
mace Posted June 22, 2016 Posted June 22, 2016 Thanks Mr. Lee for the Lisp You are a Bruce Lee in Programming fast and quickee...... "The more you give, The more you earn" (my grandpa's saying's) You are one of them GOD BLESS YOU Quote
masondino2 Posted January 17, 2019 Posted January 17, 2019 On 5/11/2009 at 9:17 PM, Lee Mac said: Three options for you *Just thought I'd write my own versions...* Let me know which one you like best [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:mt [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] cEnt mEnt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Source Text: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"TEXT"[/color][/b] [b][color=#ff00ff]"MTEXT"[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]redraw[/color][/b] cEnt [b][color=#009900]3[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] mEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Destination Text: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"TEXT"[/color][/b] [b][color=#ff00ff]"MTEXT"[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entmod[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]subst[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]redraw[/color][/b] cEnt [b][color=#009900]4[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> Incorrect Selection <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:mt2 [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] cEnt mEnt sLst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Source Text: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"TEXT"[/color][/b] [b][color=#ff00ff]"MTEXT"[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]redraw[/color][/b] cEnt [b][color=#009900]3[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=#ff00ff]"_X"[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]-4[/color][/b] . [b][color=#ff00ff]"<NOT"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#ff00ff]"TEXT,MTEXT,INSERT"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=#009900]-4[/color][/b] . [b][color=#ff00ff]"NOT>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b]x[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]redraw[/color][/b] x [b][color=#009900]2[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] sLst [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]cadr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssnamex[/color][/b] ss[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] mEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Destination Text: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"TEXT"[/color][/b] [b][color=#ff00ff]"MTEXT"[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entmod[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]subst[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] mEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> Incorrect Selection <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_regenall"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:mt3 [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] cEnt ss[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]nentsel[/color][/b] [b][color=#ff00ff]"\nSelect Source Text: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"TEXT"[/color][/b] [b][color=#ff00ff]"MTEXT"[/color][/b] [b][color=#ff00ff]"ATTRIB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]redraw[/color][/b] cEnt [b][color=#009900]3[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#ff00ff]"TEXT,MTEXT"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]foreach[/color][/b] x [b][color=RED]([/color][/b][b][color=BLUE]vl-remove-if[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]listp[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]cadr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssnamex[/color][/b] ss[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entmod[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]subst[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] x[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] x[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> Incorrect Selection <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_regenall"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Hi Lee ... I was hoping to give this a go - but why do all the lsp options you post look like gibberish? I am i missing something ... doing something wrong? cheers Quote
marko_ribar Posted January 17, 2019 Posted January 17, 2019 Here is that code without BBCode Tags : (defun c:mt (/ cEnt mEnt) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (redraw cEnt 3) (while (and (setq mEnt (car (nentsel "\nSelect Destination Text: "))) (member (cdr (assoc 0 (entget mEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget mEnt)) (entget mEnt)))) (redraw cEnt 4)) (princ "\n<!> Incorrect Selection <!>")) (princ)) (defun c:mt2 (/ cEnt mEnt sLst) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (redraw cEnt 3) (if (setq ss (ssget "_X" '((-4 . "<NOT") (0 . "TEXT,MTEXT,INSERT") (-4 . "NOT>")))) (mapcar '(lambda (x) (redraw x 2)) (setq sLst (mapcar 'cadr (ssnamex ss))))) (while (and (setq mEnt (car (nentsel "\nSelect Destination Text: "))) (member (cdr (assoc 0 (entget mEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget mEnt)) (entget mEnt))))) (princ "\n<!> Incorrect Selection <!>")) (command "_regenall") (princ)) (defun c:mt3 (/ cEnt ss) (vl-load-com) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (redraw cEnt 3) (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget x)) (entget x)))))) (princ "\n<!> Incorrect Selection <!>")) (command "_regenall") (princ)) HTH., M.R. 2 Quote
Lee Mac Posted January 17, 2019 Posted January 17, 2019 7 hours ago, masondino2 said: Hi Lee ... I was hoping to give this a go - but why do all the lsp options you post look like gibberish? I am i missing something ... doing something wrong? cheers This is caused by the new forum software no longer supporting the use of BBCode (forum formatting) within code blocks, so the BBCode is now displayed. Quote
Steven P Posted January 22, 2019 Posted January 22, 2019 On 1/17/2019 at 12:48 PM, Lee Mac said: This is caused by the new forum software no longer supporting the use of BBCode (forum formatting) within code blocks, so the BBCode is now displayed. Is there a quick and simple way to change it to normal like Marko_ribar did? (say copy to a text file or something?) Quote
Grrr Posted January 22, 2019 Posted January 22, 2019 1 hour ago, Steven P said: Is there a quick and simple way to change it to normal like Marko_ribar did? (say copy to a text file or something?) Yes. Quote
Paulsub Posted December 19, 2022 Posted December 19, 2022 Hi all Could someone help me to tweak this great mt.lisp , please. I am looking to add additional code which could keep prefixes when match number content. For example I have any text and number IL1.50 . I would like to match only number content 95.40 to get IL95.40 Many thanks for help! Quote
devitg Posted December 19, 2022 Posted December 19, 2022 6 hours ago, Paulsub said: Hi all Could someone help me to tweak this great mt.lisp , please. I am looking to add additional code which could keep prefixes when match number content. For example I have any text and number IL1.50 . I would like to match only number content 95.40 to get IL95.40 Many thanks for help! Please upload yoursample.dwg with before and after Quote
Paulsub Posted December 20, 2022 Posted December 20, 2022 Thank you for prompt respond. Please find Example for calculations.dwg and detailed explanation what results I am trying to achieve. Example for calculation.dwg with TextCalcV1-0.lsp & mt.lsp Thank you for help! TextCalcV1-0.lsp mt.lsp Example for calculation.dwg Quote
mhupp Posted December 20, 2022 Posted December 20, 2022 Might need a 3rd lisp https://www.theswamp.org/index.php?topic=53496.msg584464#msg584464 (SplitStrToStrAndNumbers "CL1.06") ("CL" 1.06) *do math stuff join back togther CL1.72 Quote
Paulsub Posted December 20, 2022 Posted December 20, 2022 (edited) 3 hours ago, mhupp said: Might need a 3rd lisp https://www.theswamp.org/index.php?topic=53496.msg584464#msg584464 (SplitStrToStrAndNumbers "CL1.06") ("CL" 1.06) *do math stuff join back togther CL1.72 Thank you mhupp for your good idea. Text should not be set specifically to CL,IL,WL etc... it could be anything, somehow text needs to be ignored and matched only numbers. I am new to lisp editing, but trying to learn. Edited December 20, 2022 by Paulsub Quote
Lee Mac Posted December 20, 2022 Posted December 20, 2022 Have you tried the program I have posted here? 1 Quote
BIGAL Posted December 21, 2022 Posted December 21, 2022 (edited) I use this one by you Lee. It is used where the text is RL 123.45 ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; s - String to process ;; ;;------------------------------------------------------------;; ;; Returns: List of numerical values found in string. ;; ;;------------------------------------------------------------;; (defun LM:ParseNumbers ( s ) ( (lambda ( l ) (read (strcat "(" (vl-list->string (mapcar (function (lambda ( a b c ) (if (or (< 47 b 58) (and (= 45 b) (< 47 c 58) (not (< 47 a 58))) (and (= 46 b) (< 47 a 58) (< 47 c 58)) ) b 32 ) ) ) (cons nil l) l (append (cdr l) (list nil)) ) ) ")" ) ) ) (vl-string->list s) ) ) (setq datum (car (LM:ParseNumbers (cdr (assoc 1 (entget (car (entsel "\nPick datum text")))))))) Edited December 21, 2022 by BIGAL Quote
Paulsub Posted December 21, 2022 Posted December 21, 2022 Thank you all for suggestions, I will try to combine lisps and hopefully I can mix something up. Quote
Paulsub Posted January 11, 2023 Posted January 11, 2023 Hi guys Is there a way to change ''Place result'' to ''replace result'' "_button : image_button { width = 8.33; height = 3.85; fixed_width = true; fixed_height = true; alignment = centered; color = -15; }" "" "textcalc : dialog { key = \"dcltitle\"; spacer;" " : row {" " : _button { label = \"+\"; key = \"+\"; }" " : _button { label = \"-\"; key = \"-\"; }" " : _button { label = \"×\"; key = \"*\"; }" " : _button { label = \"÷\"; key = \"/\"; }" " }" " spacer;" " : button { key = \"accept\"; label = \"Place Result >>\"; is_default = true; height = 2; fixed_height = true; }" " : button { key = \"cancel\"; label = \"Cancel\"; is_cancel = true; }" "}" ) instead placing result anywhere, I would need to replace existing text for example SL1.10 replace with a ''place result'' content? Quote
Paulsub Posted January 11, 2023 Posted January 11, 2023 Is there a way to adjust this script so its not eliminating specific prefixes when matching content? for exampe: IL1.10 SL1.10 etc.. Currently its replacing and leaving 1.10 (defun c:mt (/ cEnt mEnt) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (redraw cEnt 3) (while (and (setq mEnt (car (nentsel "\nSelect Destination Text: "))) (member (cdr (assoc 0 (entget mEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget mEnt)) (entget mEnt)))) (redraw cEnt 4)) (princ "\n<!> Incorrect Selection <!>")) (princ)) (defun c:mt2 (/ cEnt mEnt sLst) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (redraw cEnt 3) (if (setq ss (ssget "_X" '((-4 . "<NOT") (0 . "TEXT,MTEXT,INSERT") (-4 . "NOT>")))) (mapcar '(lambda (x) (redraw x 2)) (setq sLst (mapcar 'cadr (ssnamex ss))))) (while (and (setq mEnt (car (nentsel "\nSelect Destination Text: "))) (member (cdr (assoc 0 (entget mEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget mEnt)) (entget mEnt))))) (princ "\n<!> Incorrect Selection <!>")) (command "_regenall") (princ)) (defun c:mt3 (/ cEnt ss) (vl-load-com) (if (and (setq cEnt (car (nentsel "\nSelect Source Text: "))) (member (cdr (assoc 0 (entget cEnt))) '("TEXT" "MTEXT" "ATTRIB"))) (progn (redraw cEnt 3) (if (setq ss (ssget '((0 . "TEXT,MTEXT")))) (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (entmod (subst (assoc 1 (entget cEnt)) (assoc 1 (entget x)) (entget x)))))) (princ "\n<!> Incorrect Selection <!>")) (command "_regenall") (princ)) 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.