Jump to content

Explode Multiline text to one single line text?


fathihvac

Recommended Posts

Hello,

I need a lisp to explode a text written on multiline text to only one single line text.

Example:

"First floor

meeting

room"

When exploded must gives one single line text: "First floor meeting room"

Not gives three single line text:

"First floor"

"meeting"

"room"

Link to comment
Share on other sites

Quick hack:

(defun c:xtxt ( / e i s x )
   (if (setq s (ssget "_:L" '((0 . "MTEXT"))))
       (repeat (setq i (sslength s))
           (setq e (entget (ssname s (setq i (1- i))))
                 x (cdr (assoc 1 e))
           )
           (while (wcmatch x "*\\P*")
               (setq x (vl-string-subst " " "\\P" x))
           )
           (entmod (subst (cons 1 x) (assoc 1 e) (subst '(41 . 0.0) (assoc 41 e) e)))
           (command "_.explode" (cdr (assoc -1 e)))
       )
   )
   (princ)
)

Link to comment
Share on other sites

Not working ,It do the same as normal explode!

 

Please ensure that the 'Columns' setting (found under the 'Text' heading in the Properties Palette) for your MText is set to 'None' (No Columns) - you can change this setting for multiple MText objects simultaneously.

Link to comment
Share on other sites

  • 1 month later...
To my knowledge this setting is not exposed to AutoLISP.

 

Hope this will help..

Insert somewhere in your code. :)

 

(entmod (append e (list (cons 75 0))))
(entupd x)

MTEXT DXF 75 - 0 (Column Type - None)

Link to comment
Share on other sites

Thank you LanloyLisp ,failed to insert your code into Lee's autolisp. Could you help?

 

(defun c:xtxt (/ e i s x)
   (if (setq s (ssget "_:L" '((0 . "MTEXT"))))
       (repeat (setq i (sslength s))
           (setq e (entget (ssname s (setq i (1- i))))
	  x (cdr (assoc 1 e))
           )
           (while (wcmatch x "*\\P*")
               (setq x (vl-string-subst " " "\\P" x))
           )
(entmod (append e (list (cons 75 0)))); here is the insertion
;;sorry for the "(entupd x)" i thought "x" was the entity, at least no need to insert the entity update.
          (entmod (subst (cons 1 x) (assoc 1 e) (subst '(41 . 0.0) (assoc 41 e) e)))
 (command "_.explode" (cdr (assoc -1 e)))
       )
   )
   (princ)
)

o:)

Link to comment
Share on other sites

Or perhaps:

(defun c:xtxt ( / e i s x )
   (if (setq s (ssget "_:L" '((0 . "MTEXT"))))
       (repeat (setq i (sslength s))
           (setq e (entget (ssname s (setq i (1- i))))
                 x (cdr (assoc 1 e))
           )
           (while (wcmatch x "*\\P*")
               (setq x (vl-string-subst " " "\\P" x))
           )
           (entmod (append (subst (cons 1 x) (assoc 1 e) (subst '(41 . 0.0) (assoc 41 e) e)) '((75 . 0))))
           (command "_.explode" (cdr (assoc -1 e)))
       )
   )
   (princ)
)

Well spotted Lanloy :thumbsup:

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