Lee Mac Posted February 26, 2019 Share Posted February 26, 2019 (edited) 15 hours ago, ronjonp said: (or (vl-position (setq r (cdr (assoc 1 (entget x)))) f) (setq f (cons (strcat r ",") f))) Sorry to nitpick Ron but - Since r is concatenated with a comma when constructing the list f, vl-position will not prevent duplicate entries in the list... You also allow selection of Text & MText initially, but only include single-line Text in the final selection set. Also watch out for wildcards - selecting text containing "*" could lead to undesired results! Maybe something like this - (defun c:sstxt ( / f i l s x ) (if (setq s (ssget (setq f (list '(0 . "*TEXT") (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model")))))) (progn (repeat (setq i (sslength s)) (setq i (1- i) x (cons 1 (LM:escapewildcards (cdr (assoc 1 (entget (ssname s i)))))) ) (or (member x l) (setq l (cons x l))) ) (sssetfirst nil (ssget "_X" (append f '((-4 . "<OR")) l '((-4 . "OR>"))))) ) ) (princ) ) ;; Escape Wildcards - Lee Mac ;; Escapes wildcard special characters in a supplied string (defun LM:escapewildcards ( str ) (vl-list->string (apply 'append (mapcar '(lambda ( c ) (if (member c '(35 64 46 42 63 126 91 93 45 44)) (list 96 c) (list c) ) ) (vl-string->list str) ) ) ) ) (princ) Of course, this still doesn't account for MText formatting or long text which occupies DXF group 3... Edited February 27, 2019 by Lee Mac Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 26, 2019 Share Posted February 26, 2019 (edited) No worries Lee .. nice catch . I slapped that together with the existing code without really testing it Thanks for the input! Edited February 26, 2019 by ronjonp Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted February 27, 2019 Share Posted February 27, 2019 (edited) This also does not prevent duplicates: (or (member x l) (setq l (cons (cons 1 x) l))) BTW: Isn't vl-position faster than member? Edited February 27, 2019 by Roy_043 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 27, 2019 Share Posted February 27, 2019 4 hours ago, Roy_043 said: This also does not prevent duplicates: (or (member x l) (setq l (cons (cons 1 x) l))) BTW: Isn't vl-position faster than member? Doh! Thanks @Roy_043 - I'll update the code. vl-position is marginally faster but member is more readable in my opinion and better shows the intent of the code; I'm also half inclined to change it to (if (not (member ...))) rather than using (or). Quote Link to comment Share on other sites More sharing options...
Saqib_theleo Posted February 27, 2019 Share Posted February 27, 2019 15 hours ago, Lee Mac said: Sorry to nitpick Ron but - Since r is concatenated with a comma when constructing the list f, vl-position will not prevent duplicate entries in the list... You also allow selection of Text & MText initially, but only include single-line Text in the final selection set. Also watch out for wildcards - selecting text containing "*" could lead to undesired results! Maybe something like this - (defun c:sstxt ( / f i l s x ) (if (setq s (ssget (setq f (list '(0 . "*TEXT") (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model")))))) (progn (repeat (setq i (sslength s)) (setq i (1- i) x (cons 1 (LM:escapewildcards (cdr (assoc 1 (entget (ssname s i)))))) ) (or (member x l) (setq l (cons x l))) ) (sssetfirst nil (ssget "_X" (append f '((-4 . "<OR")) l '((-4 . "OR>"))))) ) ) (princ) ) ;; Escape Wildcards - Lee Mac ;; Escapes wildcard special characters in a supplied string (defun LM:escapewildcards ( str ) (vl-list->string (apply 'append (mapcar '(lambda ( c ) (if (member c '(35 64 46 42 63 126 91 93 45 44)) (list 96 c) (list c) ) ) (vl-string->list str) ) ) ) ) (princ) Of course, this still doesn't account for MText formatting or long text which occupies DXF group 3... hi Lee Mac, thank you for adding Mtext and wildcard character ability to the code. than you for your time and help. 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.