Short description
- MLeaderWidthFix — normalize MTEXT / MLeader (MText-content) widths using a user-specified value with an average-width default
- Computes an average width from the current selection to propose as the default input
- Applies the chosen width to MTEXT and MLeaders that use MTEXT content; TEXT is reported as not directly settable

Command:
- • MLeaderWidthFix
Description:
- Selects a set of TEXT, MTEXT, and MULTILEADER entities from the current selection context.
- Calculates a “default” width by averaging widths measured across the selected objects (TEXT extents, MTEXT bounding box width, and MLeader TextWidth when it is MTEXT-based).
- Prompts the user for a new width, showing the computed average as the default value.
- Applies the new width to MTEXT objects via Width and to MTEXT-content MLeaders via TextWidth (ContentType = 2).
- For TEXT (DText), reports that width is not directly settable and skips modification.
Helper function: (if any)
- • textbox (built-in) — used to obtain TEXT extents for a width estimate from the entity’s bounding box.
- • vla-getBoundingBox — used to compute MTEXT width from lower-left / upper-right bounding box X coordinates.
- • vl-catch-all-apply — wraps property writes to avoid hard failures when setting Width or TextWidth.
- • setenv — stores the last width value as WD_LastWidth (note: the prompt default is computed from the current selection, not read back from the environment variable).
Functionalities:
- • Selection — collects entities using ssget with filter TEXT,MTEXT,MULTILEADER; prints “No valid entities selected” if none.
- • Width measurement: TEXT — uses textbox extents and computes width from X difference of the two corners; contributes to averaging.
- • Width measurement: MTEXT — reads bounding box and computes width from ur.x – ll.x; contributes to averaging.
- • Width measurement: MLeader — only includes MLeaders with ContentType = 2 (MTEXT content) and adds TextWidth to averaging.
- • Default width — sets default to total / count if count > 0; otherwise falls back to 1.0; formats as a string with 3 decimals for the prompt.
- • User input — prompts New Width <avg>:; if user presses Enter, uses the default value.
- • Apply: TEXT — prints a message indicating TEXT width is not directly settable and skips changes.
- • Apply: MTEXT — attempts to set Width to the chosen value using a protected property write.
- • Apply: MLeader (MTEXT content) — for ContentType = 2, attempts to set TextWidth to the chosen value using a protected property write.
- • Feedback — prints Applied width: with the final numeric value.
Result:
- MTEXT objects have their Width set to the user-entered value, standardizing wrapping/column width across the selection.
- MLeaders that use MTEXT content (ContentType = 2) have their TextWidth set to the same value.
- TEXT entities are left unchanged and explicitly reported as skipped because their width is not directly settable via a simple Width property in this routine.
Images, animations etc.


Log in
