danthecadman Posted May 21, 2013 Posted May 21, 2013 Hi! I was hoping if anyone has a lisp routine for inserting brackets around text by clicking on the text and wrapping the text in brackets or something along those lines rather than clicking on text - and inserting brackets yourself individually. I've found one for curley brackets but I can't seem to get it to work and my limited knowledge of programming, I can't change the code. Cheers Quote
BIGAL Posted May 22, 2013 Posted May 22, 2013 Good idea to post what you have also pretty simple code pick 1, multiple pick pick, window etc Quote
pBe Posted May 22, 2013 Posted May 22, 2013 (defun c:brackMe (/ texts i e l) (if (setq texts (ssget "_:L" '((0 . "TEXT") (-4 . "<NOT") (1 . "`[*") (-4 . "NOT>")) ) ) (repeat (setq i (sslength texts)) (setq e (entget (ssname texts (setq i (1- i)))) l (assoc -1 e) ) (entmod (list (cons 1 (strcat "[" (cdr (assoc 1 e)) "]")) l)) ) )(princ) ) Quote
BIGAL Posted May 22, 2013 Posted May 22, 2013 (edited) here is another a quick patch of add a difference to number text ; Adds a fixed amount to a number ;(PRINC "\nTO USE JUST TYPE A2L or A2LM for multiple ") (Alert "TO USE JUST TYPE A2L or A2LM for multiple ") ;(setvar "cmdecho" 1) (setq olddimzin (getvar "Dimzin")) (setvar "dimzin" 0) (DEFUN c:A2L () ;(setq v2 (getreal "\nEnter ht adjustment ")) (setq test 1) (while (= test 1) (setq en1 (car (entsel "\nSelect text number:" ))) (if (/= en1 nil) (progn (setq el1 (strcat "(" (entget en1) ")" )) ; (setq v1 (atof (cdr (assoc 1 el1)))) (setq v1 (cdr (assoc 1 el1))) ;(setq a (+ v1 v2)) ; (setq b (rtos a 2 3)) (setq el (subst (cons 1 v1) (assoc 1 el1) el1)) (entmod el) ; (entupd en1) );progn (princ "\nplease pick again"); else );if ); while true (setq el nil) (setq en nil) (setq a nil) (setq v1 nil) (setvar "cmdecho" 1) (setvar "dimzin" olddimzin) (princ) ); END a2l DEFUN (defun c:A2LM () ;(setq v2 (getreal "\nEnter ht adjustment ")) (setq ss (ssget (list (cons 0 "Text")))) (setq len (sslength ss)) (setq x 0) (repeat len (setq en1 (ssname ss x)) (setq el1 (strcat "(" (entget en1) ")" )) ;(setq v1 (atof (cdr (assoc 1 el1)))) (setq v1 (cdr (assoc 1 el1))) ;(setq a (+ v1 v2)); ;(setq b (rtos a 2 3)) (setq el (subst (cons 1 v1) (assoc 1 el1) el1)) (entmod el) (setq x (+ x 1)) ); repeat (setq el nil ss nil) (setq en nil) (setq a nil) (setq v1 nil) (setvar "dimzin" olddimzin) (setvar "cmdecho" 1) (princ) ); END a2lm DEFUN Edited May 24, 2013 by BIGAL Quote
alanjt Posted May 22, 2013 Posted May 22, 2013 Slight mod on pBe's code: (defun c:TEst (/ ss i e d s) (if (setq ss (ssget "_:L" '((0 . "TEXT") (-4 . "<NOT") (1 . "`[*`]") (-4 . "NOT>")))) (repeat (setq i (sslength ss)) (setq e (ssname ss (setq i (1- i))) d (entget e) s (cdr (assoc 1 d)) ) (entmod (list (cons 1 (cond ((and (wcmatch s "`[*") (not (wcmatch s "*`]"))) (strcat s "]")) ((and (not (wcmatch s "`[*")) (wcmatch s "*`]")) (strcat "[" s)) ((strcat "[" s "]")) ) ) (cons -1 e) ) ) ) ) (princ) ) Quote
pBe Posted May 22, 2013 Posted May 22, 2013 here is another a quick patch of add a difference to number text Whats adding a diffrence to a number got to do with this Bigal? Did i miss-read the thread title? or is this a PM thing? Quote
Lee Mac Posted May 22, 2013 Posted May 22, 2013 Another alternative: ([color=BLUE]defun[/color] c:test ( [color=BLUE]/[/color] i e s x ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_:L"[/color] '((0 . [color=MAROON]"TEXT"[/color]) (1 . [color=MAROON]"~`[*`]"[/color])))) ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]setq[/color] e ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) x ([color=BLUE]assoc[/color] 1 e) ) ([color=BLUE]entmod[/color] ([color=BLUE]subst[/color] ([color=BLUE]cons[/color] 1 ([color=BLUE]strcat[/color] [color=MAROON]"["[/color] ([color=BLUE]vl-string-trim[/color] [color=MAROON]"[]"[/color] ([color=BLUE]cdr[/color] x)) [color=MAROON]"]"[/color])) x e)) ) ) ([color=BLUE]princ[/color]) ) Quote
alanjt Posted May 22, 2013 Posted May 22, 2013 Another alternative: Even better. I completely forgot about vl-string-trim. Quote
pBe Posted May 22, 2013 Posted May 22, 2013 Another alternative: (setq s (ssget "_:L" '((0 . "TEXT") (1 .[color="blue"][b] "~[/b][/color]`[*`]")))) ..... ) Bummer, I totally forgotten all about that switch. Even better. I completely forgot about vl-string-trim. Same here dude Quote
alanjt Posted May 22, 2013 Posted May 22, 2013 Bummer, I totally forgotten all about that switch. It's definitely useful when only checking against one string. Quote
BIGAL Posted May 24, 2013 Posted May 24, 2013 For anyone code changed shouldn't drink scotch and post code at same time. Quote
neophoible Posted May 24, 2013 Posted May 24, 2013 For anyone code changed shouldn't drink scotch and post code at same time.Good tip! I'll keep that in mind. :beer:But I can do that sort of thing without any outside help! Quote
pBe Posted May 25, 2013 Posted May 25, 2013 For anyone code changed shouldn't drink scotch and post code at same time. That explains a lot Bigal 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.