Jump to content

Recommended Posts

Posted

Hi All Engineer 

Here is the door or window symbol and its number below it
I need to merge the two texts into one text
I was using the txt2mtxt function

But you only need to select every two that are close together
If all are selected, there will be a problem

Is there a Lisp for this process?
So that it recognizes writings that are close to each other and combines them

https://www12.0zz0.com/2024/02/15/09/496206091.png

 

Posted

By artificial intelligence
I extracted this lisp but it didn't work
It may need a little modification


 

(defun c:MergeCloseTexts ( )
  (setq entlist (ssget))
  (while (entnext entlist)
    (setq ent (entnext entlist))
    (if (and (eq (enttype ent) "TEXT")
             (not (zerop (distance (getpoint ent) (getpoint (entnext ent))))))
      (command "_.txt2mtxt" ent (entnext ent))
    )
  )
)

 

FF_DOOR_WINDOWS.dwg

Posted

I am not as smart as AI, so my program is longer:

(defun c:pp()
  (setq ss (ssget "I" (list '(0 . "TEXT")))
	d (getdist "max distance? "))
  (while (> (sslength ss) 0)
    (setq t1 (ssname ss 0)
	  poz1 (cdr (assoc 10 (entget t1))))
    (ssdel t1 ss)
    (setq i -1 gotIt nil)
    (while (not gotIt)
      (setq t2 (ssname ss (setq i (1+ i)))
	    poz2 (cdr (assoc 10 (entget t2)))
	    gotIt (< (distance poz1 poz2) d))
      )
    (ssdel t2 ss)
    (bind t1 t2)
    )
  )  
  (defun bind (a b)
    (setq ya (caddr (assoc 10 (entget a)))
	  yb (caddr (assoc 10 (entget b)))
	  lst (if (> ya yb) (list a b) (list b a))
	  el (entget (car lst))
	  tx (cdr (assoc 1 el))
	  tx (strcat tx " / " (cdr (assoc 1 (entget (cadr lst)))))
	  el (subst (cons 1 tx) (assoc 1 el) el)
	  )
    (entmod el)
    (entdel (cadr lst))
    )

When it asks for "max distance" enter how close is a text to its pair. You may answer with two clicks to define the distance, or by entering it from the keyboard. For a given text, the program will search its pair within that distance.

 

Edit: I just seen that you try to make an Mtext... This program will make a Text. Sorry, no more time to change the Lisp... :(

Posted
1 hour ago, fuccaro said:

I am not as smart as AI, so my program is longer:

 

... but your programme works?

Posted

@alhlhli

In the program I posted for you, you could change the call for the bind function (bind t1 t2) with a call for the text2mtxt and you will get the result as mtext

 

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