Jump to content

Re set texts as one ward


Dayananda

Recommended Posts

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.

Link to comment
Share on other sites

(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 by Jonathan Handojo
Trim beginning and ending spaces
  • Thanks 1
Link to comment
Share on other sites

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 by Lee Mac
Link to comment
Share on other sites

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))

Link to comment
Share on other sites

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 by BIGAL
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...