Code Red > AutoLISP (Vanilla / Visual)

Mtext Word wrap removal

(1/4) > >>

Biscuits:
I'm looking for a routine/macro to remove word wrap on existing mtext without all the properties changing in the mtext dialogue box. Looking for a system variable change, lisp or VBA. It can be global or through a single selection. Does anyone have any ideas?
Using ACAD2002 on Windows 2000. Thanks

Mark:
Not perfect! Might fall down if you have a lot of formatting in your MTEXT.


--- Code: ---


(defun c:blastReturns (/ rm-returns ent entlst str new_str)

  (defun rm-returns (str)
    (while (wcmatch str "*\\P*")
      (setq str (vl-string-subst " " "\\P" str))
    )
    str
  )

  (if (setq ent (car (entsel "\nSelect MTEXT: ")))
    (progn

      (setq entlst  (entget ent)
   str    (cdr (assoc 1 entlst))
   new_str (rm-returns str)
      )

      (setq entlst
    (subst (cons 1 new_str) (assoc 1 entlst) entlst)
      )
      (entmod entlst)
    )
  )

  (princ)
)

--- End code ---

Mark:
Newer version, more error checking.

--- Code: ---
(defun c:blastReturns (/ rm-returns ent entlst str new_str)

  (defun rm-returns (str)
    (while (wcmatch str "*\\P*")
      (setq str (vl-string-subst " " "\\P" str))
    )
    str
  )

  (if (setq ent (car (entsel "\nSelect MTEXT: ")))
    (progn
      (setq entlst (entget ent))
      (if (= (cdr (assoc 0 entlst)) "MTEXT")
(progn
 (setq str (cdr (assoc 1 entlst))
new_str (rm-returns str)
entlst (subst (cons 1 new_str) (assoc 1 entlst) entlst)
 )
 (entmod entlst)
); progn
(princ "\nThat wasn't MTEXT was it!!")
      ); if
    )
  )

  (princ)
)

--- End code ---

Jeff_M:
While Mark's removes hard returns in Mtext, I understood that Biscuit wanted to remove the auto word wrap when the text doesn't fit all on one line. The following does that.

--- Code: ---
(defun c:nowrap (/ doc ss)
  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (if (ssget '((0 . "MTEXT")))
    (progn
      (setq ss (vla-get-activeselectionset doc))
      (vlax-for ent ss
(vla-put-width ent 0)
)
      )
    )
  (princ)
  )

--- End code ---

Biscuits:
Thank you. I really appreciate the effort but what I need to accomplish is to change the mtext width property to (no wrap) on existing mtext. I'm not code-literate enough to understand what your routine does, but it doesn't change this property value.

Navigation

[0] Message Index

[#] Next page

Go to full version