Hi, all.
I've looked all around but couldn't find a solution for this... Is there a way to remove carriage returns from MText and MLeaders?
For example, I'd like to remove the return from this:
"top of signal
head el= ##.##"
and turn it into:
"top of signal head el= ##.##".
I tried using "Find" and looked for "signal/Phead", "signal^phead", and "signal*head" (/P, ^p, and *), but those don't work.
Any help is appreciated.
Edgar
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by Kent1Cooper. Go to Solution.
There is nothing built-in will do what you want: ask in the LISP forum https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130 how to create a Lisp to perform the COMBINE PARAGRAPHS option inside mtext if you do not want to do it one object at a time manually.
@ebsoares wrote:
... Is there a way to remove carriage returns from MText and MLeaders?
....
I tried using "Find" and looked for "signal/Phead", "signal^phead", and "signal*head" (/P, ^p, and *), but those don't work.
....
For one thing, it's \P [backslash, not forward-slash]. But with that correction, it's not difficult. In rather simple terms [lightly tested]:
(defun C:MDE ; = Mtext/Mleader: Delete Enter(s) (/ esel obj) (if (and (setq esel (entsel "\nSelect Mtext/Mleader from which to remove Enter(s): ")) (setq obj (vlax-ename->vla-object (car esel))) (wcmatch (substr (vla-get-ObjectName obj) 5) "MText,MLeader") (wcmatch (vla-get-TextString obj) "*\\P*"); contains any ); and (while (wcmatch (vla-get-TextString obj) "*\\P*"); then ;; [in (while) function for possibly more than one] (vla-put-TextString obj (vl-string-subst "" "\\P" (vla-get-TextString obj))) ); while ); if (princ) ); defun
(vl-load-com)
Consider whether you want to replace the Enters with spaces, rather than with nothing [simply remove them] as the above code does, which may be the better alteration for your example [to get "signal head" rather than "signalhead"], which would be equivalent to what the Combine Paragraphs option in MTEDIT that @pendean mentioned. [That's slightly tedious to do with multiple objects, because you have to get into the editor and then select some or all of the text content before that option becomes available. I recall other threads wishing that the content would all be pre-selected when you get into the Mtext editor, as it is in the plain-Text editor.]
Possible enhancements: allow selecting more than one at a time [fairly simple adjustment]; include Dimensions which can also contain them [more code required than just adding the entity type, because the VLA property name for the content is different]; notify you if you didn't pick the right kind of thing, and/or ask again until you do.
[Your post "crossed in the mail" with some of the Editing I just did to mine, which suggests some of the same things.]
Being in the Customization Forum instead of here might be better for the sake of others finding it when looking for the same kind of thing, if that's the only Forum they Search. You could do a "Report" and request that of the moderator.
Check this out [again, minimally tested]:
(defun C:MDE ; = Mtext/Mleader: Delete Enter(s) (/ mdess n obj) (prompt "\nTo Delete Enters from Mtext/Multileaders,") (if (setq mdess (ssget "_:L" '((0 . "MTEXT,MULTILEADER")))) (repeat (setq n (sslength mdess)); then -- step through (setq obj (vlax-ename->vla-object (ssname mdess (setq n (1- n))))) (while (wcmatch (vla-get-TextString obj) "*\\P*") ;; in (while) for possible multiple Enters [substitutes only one at a time] (vla-put-TextString obj (vl-string-subst " " "\\P" (vla-get-TextString obj))) ); while ); repeat ); if (princ) ); defun (vl-load-com)
Kent1Cooper wrote:....
Possible enhancements: ... include Dimensions which can also contain them...; notify you if you didn't pick the right kind of thing....
Here's a version that includes both of those:
;| RemoveEnters.lsp [command name: REMD] To Remove Enters [hard returns, "\P"] in the text content of Mtext, Multileaders and
Dimension overrides. Replaces them with spaces, to be like the "Combine Paragraphs"
option in the Mtext editor, but for multiple objects and all three types at once. Kent Cooper, 15 August 2016 |; (defun C:REMD ; = Remove Enter(s) from Mtext/Mleaders/Dimensions (/ ss n obj prop) (prompt "\nTo Delete Enters from Mtext/Multileaders/Dimensions,") (if (setq ss (ssget "_:L" '((0 . "MTEXT,MULTILEADER,DIMENSION")))) (repeat (setq n (sslength ss)); then -- step through (setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))) prop (strcat "Text" (if (wcmatch (substr (vla-get-ObjectName obj) 5) "MText,MLeader") "String" ; then "Override" ; else [Dimension] ); if ); strcat & prop ); setq (while (wcmatch (vlax-get obj prop) "*\\P*") ;; in (while) for possible multiple Enters [substitutes only one at a time] (vlax-put obj prop (vl-string-subst " " "\\P" (vlax-get obj prop))) ); while ); repeat (prompt "\nNo Mtext/MLeaders/Dimensions [on unlocked Layers] selected.") ); if (princ) ); defun (vl-load-com)
Can't find what you're looking for? Ask the community or share your knowledge.