明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1253|回复: 2

请教版主、高手,多字(mtext)vba程序实现居中怎样处理?

[复制链接]
发表于 2013-10-22 16:58:39 | 显示全部楼层 |阅读模式
请教版主、高手,多字(mtext)vba程序实现居中怎样处理?单行文字使用Alignment,多行文字不知怎样处理,谢谢!
 楼主| 发表于 2013-10-22 17:08:40 | 显示全部楼层
Sub Example_AttachmentPoint()
    Dim MTextObj As AcadMText
    Dim width As Double
    Dim text As String
    Dim count As Integer
    Dim attachPoint As String
    Dim corner(0 To 2) As Double
        
    corner(0) = 3#: corner(1) = 3#: corner(2) = 0#
    width = 10
    text = "Hello, World."
    ' Creates a MText object in model space
    Set MTextObj = ThisDrawing.ModelSpace.AddMText(corner, width, text)

    For count = 1 To 9
        MTextObj.AttachmentPoint = count
   
        ' Gets the attachment point of an MText object
        attachPoint = Choose(MTextObj.AttachmentPoint, "TopLeft", "TopCenter", "TopRight", "MiddleLeft", "MiddleCenter", "MiddleRight", "BottomLeft", "BottomCenter", "BottomRight")
   
        ThisDrawing.Regen True
        MsgBox "The attachment point of the MText is now: " & attachPoint, vbInformation, "AttachmentPoint Example"
    Next
End Sub
  
 楼主| 发表于 2013-10-23 10:09:58 | 显示全部楼层
mtxt.AttachmentPoint = AcAttachmentPoint.acAttachmentPointMiddleCenter  '多行文字居中
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 12:34 , Processed in 0.163250 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表