RotateMtextVport

Short description

Rotate Text and Mtext in Viewport Aligns TEXT objects to viewport rotation while resetting MTEXT to horizontal orientation.

Command:

Command: RotateMtextVport

Description:

This command adjusts text orientation based on the current viewport rotation:
  • MTEXT objects are reset to 0° rotation (horizontal) with top-left attachment point
  • TEXT objects are rotated to match the viewport’s UCS X-axis angle with left alignment
Useful when working in rotated viewports where text readability needs correction.

Helper function: (if any)​

Helper Functions:
  • vl-load-com – Loads Visual LISP COM support
  • angle – Calculates viewport rotation angle
  • trans – Transforms coordinates from UCS to WCS
  • vlax-ename->vla-object – Converts entity name to VLA object
  • vlax-put – Sets object properties

Functionalities:

Functionalities:
  • Calculates current viewport rotation by measuring UCS X-axis angle in WCS
  • Prompts user to select TEXT and/or MTEXT objects
  • Iterates through selected objects and applies rotation based on object type
  • For MTEXT: sets rotation to 0° and attachment point to top-left
  • For TEXT: sets rotation to viewport angle and alignment to left
  • Displays message if no objects are selected

Result:

Result:
  • All selected MTEXT objects become horizontally oriented (0° rotation)
  • All selected TEXT objects rotate to match the viewport orientation
  • Text readability is improved in rotated viewports

Images, animations etc.

Pixel

XAML code:

<ResourceDictionary
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:src="clr-namespace:Autodesk.Windows;assembly=AdWindows">
 
 <src:RibbonToolTip x:Key="RotateMtextVport">
 <src:RibbonToolTip.ExpandedContent>
 <StackPanel>
 <TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: RotateMtextVport </Bold>
<LineBreak/>
<Hyperlink>AI+https://www.cadtutor.net/forum/topic/76283-rotate-to-match-view/</Hyperlink>
<LineBreak/>
<Bold>Description</Bold><LineBreak/>
This AutoLISP program <Span Foreground="DarkRed">RotateMtextVport.lsp</Span> adjusts the rotation of selected <Span Foreground="DarkRed">TEXT</Span> and <Span Foreground="DarkRed">MTEXT</Span> objects relative to the current viewport orientation.<LineBreak/>
It ensures MTEXT is upright and TEXT aligns with the viewport’s UCS X-axis.<LineBreak/>

<Bold>Functionalities</Bold><LineBreak/>
• Retrieves the current viewport rotation angle from the UCS X-axis.<LineBreak/>
• Selects both <Span Foreground="DarkRed">TEXT</Span> and <Span Foreground="DarkRed">MTEXT</Span> entities for processing.<LineBreak/>
• Sets MTEXT rotation to <Span Foreground="DarkRed">0.0</Span> and attachment point to <Span Foreground="DarkRed">Top Left</Span>.<LineBreak/>
• Sets TEXT rotation to match the viewport rotation angle and alignment to <Span Foreground="DarkRed">Left</Span>.<LineBreak/>
• Processes multiple selected objects in a loop.<LineBreak/>
• Provides a message if no valid objects are selected.<LineBreak/>

<Bold>Important Notes</Bold><LineBreak/>
• Command to run this tool: <Span Foreground="DarkRed">RotateMtextVport</Span>.<LineBreak/>
• Uses ActiveX properties (<Span Foreground="DarkRed">vlax-put</Span>) to change rotation and alignment.<LineBreak/>
• Designed to standardize text orientation within viewports for consistent presentation.<LineBreak/>


</TextBlock>
 
			
<Grid>
<Image Source="RotateMtextVport_00.jpg" Stretch="Uniform"/>
</Grid>
<Grid>
<Image Source="RotateMtextVport_01.jpg" Stretch="Uniform"/>
</Grid>
					

  </StackPanel>
 </src:RibbonToolTip.ExpandedContent>
 </src:RibbonToolTip>
 
 
 
 
 
</ResourceDictionary>

Additional info:

Share this page:

Leave a Reply

Page Tag: 🏷️ Alignment

  • RotateMtextVport

    Short description Rotate Text and Mtext in Viewport Aligns TEXT objects to viewport rotation while resetting MTEXT to horizontal orientation. Command: Command: RotateMtextVport Description: This command adjusts text orientation based on the current viewport rotation: MTEXT objects are reset to 0° rotation (horizontal) with top-left attachment point TEXT objects are rotated to match the viewport’s…