Short description
Sort / Purpose: Convert multiple selected TEXT and MTEXT entities into a single MTEXT object while keeping each original line as a separate paragraph.
• Scope: Works on standard text objects in the current space and merges them into one formatted MTEXT container.
• Goal: Simplify editing and formatting by replacing several separate text items with one unified MTEXT that preserves visual layout and underlines.
Command:
Command name: T2M2
How to run: Load the LISP file, then type T2M2 in the command line and press Enter.
• Selection: When prompted, select any combination of TEXT and MTEXT entities to be converted into one MTEXT object.
Description:
• Text collection: Builds an internal list of the text strings from all selected TEXT and MTEXT entities in the selection set.
• Underline conversion: Scans each string for “%%U” underline markers and replaces them with MTEXT underline codes using L and l so underlining is preserved correctly.
• Paragraph handling: For plain TEXT entities, prefixes each string with P so every original DText line becomes its own paragraph inside the final MTEXT.
• Concatenation: Concatenates all processed strings into one combined MTEXT content string in selection order.
• Placement: Creates a new MTEXT object at the insertion point of the first selected entity, using its text width to define the wrapping width.
• Property transfer: Copies key visual properties from the first entity to the new MTEXT such as Layer, Color, StyleName, and Height, as well as alignment and rotation.
• Cleanup: After successfully creating the new MTEXT, deletes all original TEXT and MTEXT entities that were part of the selection.
• No selection case: If no valid text objects are selected, prints a short message instead of doing any changes.
Helper function: (if any)
Local helper functions inside the routine:
• *error*: Custom error handler that cleans up the created MTEXT object and any stored entities if an error or user cancel occurs.
• align_Mt: Determines a compatible MTEXT attachment point from either an existing MTEXT or a TEXT alignment setting so the new MTEXT aligns like the source.
• Get_MTOffset_pt: Computes a vertical offset point based on MTEXT height, bounding box, and attachment point, prepared for possible alignment offset logic.
• GetTextWidth: Calculates an appropriate text width for the new MTEXT, using TEXTBOX on TEXT entities or the Width property on MTEXT objects.
• ReplaceUnderline: Walks through each text string, converting “%%U” underline markers into MTEXT underline on and off codes L and l, ensuring open underlines are properly closed at the end if needed.
Used system and VLA calls:
• vl-load-com: Enables use of ActiveX and VLA functions within the routine.
• vla-get-ActiveDocument: Gets the current drawing document object.
• vla-get-ModelSpace / Paperspace: Chooses the correct space object depending on where the user is working.
• vla-AddMText: Creates the final MTEXT entity containing the combined text.
Functionalities:
• Multi text merge: Merges multiple individual TEXT and MTEXT items into a single MTEXT object for easier global editing.
• Paragraph preservation: Keeps each original TEXT line as its own paragraph inside MTEXT so line structure is not lost.
• Underline aware: Translates “%%U” underline codes into proper MTEXT underline formatting that works in modern text styles.
• Style consistency: Uses the first selected text object as a template for layer, color, text style, and height, ensuring the new MTEXT matches the existing annotation style.
• Alignment and rotation: Attempts to reproduce the same alignment and rotation of the first entity so the new MTEXT appears in the same visual position and orientation.
• Space aware: Automatically works in model space or paper space depending on the current active space of the document.
• Automatic cleanup: Removes all original text entities after creation of the MTEXT, preventing duplicates on screen.
Result:
Result: All selected TEXT and MTEXT objects are replaced by a single MTEXT entity that preserves line order, paragraph separation, and underline formatting while matching the original visual style.
• Cleaner editing: You can now edit the combined content in one MTEXT editor instead of handling many separate text entities.
• Consistent appearance: The new MTEXT inherits layer, color, style, height, alignment, and rotation from the first selected text item.
• Preserved structure: Individual lines from plain TEXT are kept as separate paragraphs, and underline codes are correctly converted to MTEXT format.
• Non reversible by command: Original text entities are deleted once the MTEXT is created, so the change is final unless you use Undo.
Copy code:
Images, animations etc.
Log in to download.
Log in
Log in
Additional info:
Based on / Source code:
Open Website
Share this page:
Subscribe
Login
0 Comments
Oldest
