Join two separate texts

Join two separate texts

Oliver_C3D
Advocate Advocate
1,531 Views
16 Replies
Message 1 of 17

Join two separate texts

Oliver_C3D
Advocate
Advocate

Hi

I have a file whose texts are separated in decimal places. I want to merge them before and after decimal places with Position Z correct

Oliver_C3D_0-1650739173891.png

 

0 Likes
Accepted solutions (2)
1,532 Views
16 Replies
Replies (16)
Message 2 of 17

hak_vz
Advisor
Advisor

This can be done in many ways and it's easy to do.

Let say,  we select all point (donuts....) representing a decimal point. Find red text and blue text near to point and join them together. Simple task but it requires that you post sample dwg (do this with every request to help us in creating code).

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 17

calderg1000
Mentor
Mentor

Regards @Oliver_C3D 

Try this code. If it doesn't fit what you require. Please post an example Dwg.

(defun c:Jtext (/ s ltx i en tx ltx pins lay h ltf tt)
  (setq s (ssget '((0 . "text"))))
  (setq ltx ())
  (repeat (setq i (sslength s))
    (setq en  (entget (ssname s (setq i (1- i))))
          tx  (cdr (assoc 1 en))
          ltx (cons tx ltx)
    )
  )
  (setq pins (cdr (assoc 10 en))
        lay  (cdr (assoc 8 en))
        h    (cdr (assoc 40 en))
        ltf  (reverse ltx)
        tt   (strcat (nth 0 ltf) (nth 1 ltf) (nth 2 ltf))
  )
  (setq pins (mapcar '+ pins (list 0. 0. (atof tt))))
  (entmake
    (list (cons 0 "text") (cons 8 lay) (cons 10 pins) (cons 40 h) (cons 1 tt))
  )
  (vl-cmdf "erase" s "")
  (princ)
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 4 of 17

Sea-Haven
Mentor
Mentor

Really need a dwg, one software package I have used would make the decimal point the actual points X&Y&Z this is tricky to work backwards from as the font starts to impact. Even down to the characters used compare 111 to 222

0 Likes
Message 5 of 17

Kent1Cooper
Consultant
Consultant

Just to confirm what I think it looks like in the image [and which would also be answered by a sample drawing]:  Is the decimal point also a Text object?  Not something else, such as a Point, or a Block, or...?

Kent Cooper, AIA
0 Likes
Message 6 of 17

Oliver_C3D
Advocate
Advocate
0 Likes
Message 7 of 17

ВeekeeCZ
Consultant
Consultant
Accepted solution

It would so nice if you actually think about what you're doing.

 

(vl-load-com)

(defun c:C3DJoinSepHeights ( / :strcat e i c d x)

  (defun :strcat (x d)
    (setq x (vl-string-trim " " x)
	  d (vl-string-subst ". 0" ".  " d)
	  d (vl-string-subst "." ". " d))
    (if (wcmatch d "*`%100")
      (setq x (itoa (1+ (atoi x)))
	    d ".00"))
    (strcat x d))

  ; ---------------------------------------------------------------------------------------------------

  (if (setq s (ssget '((0 . "TEXT"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    c (cdr (assoc 1 (entget e))))
      (if (wcmatch c "`.*")
	(setq d (cons (list e c (reverse (cdr (reverse (cdr (assoc 10 (entget e))))))) d))
	(setq x (cons (list e c (reverse (cdr (reverse (cdr (assoc 10 (entget e))))))) x)))))
  
  (foreach e d
    (and (setq m (car (vl-remove-if-not '(lambda (y) (< (abs (- (distance (last e) (last y)) 8.58)) 0.01)) x)))
	 (entmod (subst (cons 1 (:strcat (cadr m) (cadr e)))
			(assoc 1 (entget (car e)))
			(entget (car e))))
	 (entdel (car m))))
  (princ)
  )

 

0 Likes
Message 8 of 17

pbejse
Mentor
Mentor
Accepted solution
(defun c:Merger	(/ ss i e ent data)
  (if (setq ss (ssget "_:L" '((0 . "TEXT") (1 . ". %#*,. #*, #**"))))
    (repeat (setq i (sslength ss))
      (setq e	 (ssname ss (setq i (1- i)))
	    ent	 (entget e)
	    data (mapcar '(lambda (d) (cdr (assoc d ent))) '(1 10))
      )

      (if (/= (setq zValue (last (cadr data))) 0.0)
	(entmod
	  (subst (cons 1
		       (strcat (rtos zValue 2 0)
			       "."
			       (vl-string-left-trim ". %" (Car data))
		       )
		 )
		 (assoc 1 ent)
		 ent
	  )
	)
	(vla-delete (vlax-ename->vla-object e))
      )
    )
  )
  (princ)
)

HTH

 

Message 9 of 17

ВeekeeCZ
Consultant
Consultant

Since my remark still applies, it is probably worth noting the differences (not saying that mine is right and the other is wrong)

 

source - mine - pbe

 770 .  7 - 770.07 - 770.7

 769 . %100 - 770.00 - 769.100

0 Likes
Message 10 of 17

Oliver_C3D
Advocate
Advocate

@ВeekeeCZ  It would be better if the value was in position z after joining the text

0 Likes
Message 11 of 17

ВeekeeCZ
Consultant
Consultant

@Oliver_C3D wrote:

@ВeekeeCZ  It would be better if the value was in position z after joining the text


 

Not sure what that means. Both codes keep the original z value. 

 

Edit: Now I see what you mean, probably...

Try this code - rewritten according to smart @pbejse 's algorithm.

 

(vl-load-com)

(defun c:C3DJoinSepHeights ( / :strcat e i c d x)
  
  (defun :strcat (x d)
    (setq x (vl-string-trim " " x)
	  d (vl-string-subst "." ".  " d)
	  d (vl-string-subst "." ". " d))
    (if (wcmatch d "`.#")
      (setq d (strcat d "0")))
    (if (wcmatch d "*`%100")
      (setq x (itoa (1+ (atoi x)))
	    d ".00"))
    (strcat x d))
  
  ; ---------------------------------------------------------------------------------------------------
  
  (if (setq s (ssget '((0 . "TEXT"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    c (cdr (assoc 1 (entget e))))
      (cond ((wcmatch c "`.*")	(setq d (cons (list e c (cdr (assoc 10 (entget e)))) d)))
	    ((wcmatch c "*`.*"))
	    (T (entdel e)))))
  
  (foreach e d
    (and (setq z (last (last e)))
	 (entmod (subst (cons 1 (setq z (:strcat (rtos z 2 0) (cadr e))))
			(assoc 1 (entget (car e)))
			(entget (car e))))
	 (entmod (subst (list 10 (car (last e)) (cadr (last e)) (atof z))
			(assoc 10 (entget (car e)))
			(entget (car e))))))
  (princ)
  )

 

Message 12 of 17

john.uhden
Mentor
Mentor

@Oliver_C3D 

I think someone where you work has a bad habit, especially if you don't plot in color.

But aren't the responders wonderful... to try to provide you a solution.  I could swear they spend more time helping than working, but that could be because they are independently wealthy and don't have to work.  🤑  I dunno.

John F. Uhden

0 Likes
Message 13 of 17

Oliver_C3D
Advocate
Advocate

thank you very much @ВeekeeCZ 
There is only one problem if the number is 755.7, for example, it changes to 755.07, which is wrong. That's right, 755.70

0 Likes
Message 14 of 17

ВeekeeCZ
Consultant
Consultant

Ok, the last code was updated.

0 Likes
Message 15 of 17

calderg1000
Mentor
Mentor

Regards @Oliver_C3D 

Since you already have a solution to do it by selecting several texts at the same time. Update my initial code to join the texts selecting two by two, consecutively.

In the case of texts that represent their elevation and it is possible that with this a TIN surface will be built, it surprises me that a fixed insertion point is not required.

(defun c:Jtext ( / s ltx i en tx ltx pins lay h tt)
  (while
  (setq s (ssget '((0 . "text"))))
  (setq ltx ())
  (repeat (setq i (sslength s))
    (setq en  (entget (ssname s (setq i (1- i))))
          tx  (cdr (assoc 1 en)))
          (repeat 2
          (setq tx(vl-string-subst "" " " tx)))
          (setq ltx (cons tx ltx))
  )
  (setq pins (mapcar '+ (cdr (assoc 10 en)) '(3.18 0 0))
        lay  (cdr (assoc 8 en))
        h    (cdr (assoc 40 en))
        tt   (strcat (nth 0 ltx) (nth 1 ltx))
  )
  (setq pins (mapcar '+ pins (list 0. 0. (atof tt))))
  (entmake
    (list (cons 0 "text") (cons 8 lay) (cons 10 pins) (cons 40 h) (cons 1 tt)(cons 73 0))
  )
  (vl-cmdf "_erase" s "")
  )
  (princ)
)

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 16 of 17

Sea-Haven
Mentor
Mentor
Converting text to 2d points for making TIN's has that problem where is the true point, some point is insertion point, I know of the decimal point is correct point, this is hard to work out.
0 Likes
Message 17 of 17

john.uhden
Mentor
Mentor

@Sea-Haven 

IMHO, it's a stupid idea to use just text to represent a survey point, unless maybe you are preparing an approximate topo survey of thousands of unblemished acres.  Certainly DCA->Softdesk->Land Desktop never provided for such an approach.

John F. Uhden

0 Likes