Dayananda Posted November 9, 2020 Posted November 9, 2020 This is the texts in my cad drawing 05 02 03 those are separate texts, But in one line. I want change this arrangement as 05,02,03 Please help me. Quote
Jonathan Handojo Posted November 9, 2020 Posted November 9, 2020 (edited) (defun test (str) (vl-list->string (subst 44 32 ((lambda (x) (vl-remove nil (mapcar '(lambda (a b) (if (not (= a b 32)) b) ) (cons nil x) x ) ) ) (vl-string->list (vl-string-trim " "str)) ) ) ) ) Edited November 9, 2020 by Jonathan Handojo Trim beginning and ending spaces 1 Quote
Lee Mac Posted November 9, 2020 Posted November 9, 2020 (edited) Assuming that the source text "05", "02" and "03" are all individual text objects, I wrote a Merge Text program back in 2012 which should be able to convert these to a single text object, which could be tweaked to use a comma delimiter in place of a space - I'll see if I can find it. EDIT: Found it: Edited November 9, 2020 by Lee Mac Quote
rlx Posted November 9, 2020 Posted November 9, 2020 Nice code @Jonathan Handojo , only thing is to insert a cdr between your vl-list->string and (subst 44 32 so output doesn't begin with a comma Quote
Jonathan Handojo Posted November 9, 2020 Posted November 9, 2020 6 hours ago, rlx said: Nice code @Jonathan Handojo , only thing is to insert a cdr between your vl-list->string and (subst 44 32 so output doesn't begin with a comma Valid point. Easier if it's just changed to: (vl-string->list (vl-string-trim " " str)) Quote
BIGAL Posted November 10, 2020 Posted November 10, 2020 (edited) This will do vertical as well, as it uses ssget with no options you can just pick pick etc for the order. You can though when asked to select type F this will drop you into Fence mode so can drag a line over the text, you will though need to press enter twice to exit the fence & selection. You can use a combo if you want pick select and fence. It updates the 1st text and erases the rest if that is what you want. (defun c:txtadds ( / ss ) (setq ss (ssget (list (cons 0 "TEXT")))) (setq str "" x -1) (setq ent (entget (ssname ss 0))) (repeat (- (sslength ss) 1) (setq str (strcat str (cdr (assoc 1 (entget (ssname ss (setq x (+ x 1)))))) "," )) ) (setq str (strcat str (cdr (assoc 1 (entget (ssname ss (+ x 1))))))) (entmod (subst (cons 1 str) (assoc 1 ent) ent)) (setq x 0) (repeat (- (sslength ss) 1) (command "erase" (ssname ss (setq x (+ x 1))) "") ) (princ) ) I expect Lee's answer will be a bit smarter and use a selection sorting text on X or Y so can be horizontal or vertical. Interesting using "fence" in Autocad order is as per drag but in Bricscad not the case. Edited November 10, 2020 by 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.