• AutoCAD VBA简单文字操作


    AutoCAD VBA简单文字操作,包括几个简单的文字操作函数,代码如下。

    Public Function AddText(ByVal text As String, ByVal ptinsert As Variant, ByVal height As Double) As AcadText
    Set AddText = ThisDrawing.ModelSpace.AddText(text, ptinsert, height)
    End Function
    Public Function AddTextHA(ByVal text As String, ByVal ptinsert As Variant, ByVal height As Double, ByVal angle As Double) As AcadText
    Dim objText As AcadText
    Set objText = ThisDrawing.ModelSpace.AddText(text, ptinsert, height)
    objText.Rotate ptinsert, angle
    objText.udate
    Set AddTextHA = objText
    End Function
    Public Function AddMtext(ByVal ptinsert As Variant, ByVal width As Double, ByVal text As String) As AcadMText
    Set AddMtext = ThisDrawing.ModelSpace.AddMtext(ptinsert, width, text)
    End Function
    Public Function AddMtextHA(ByVal ptinsert As Variant, ByVal width As Double, ByVal text As String, ByVal height As Double, ByVal angle As Double) As AcadMText
    Dim objMtext As AcadMText
    Set objMtext = ThisDrawing.ModelSpace.AddMtext(ptinsert, width, text)
    objMtext.height = height
    objMtext.Rotate = angle
    Set AddMtextHA = objMtext
    End Function
    Public Sub TestText()
    Dim ptinsert(2) As Double
    ptinsert(0) = 100: ptinsert(1) = 100: ptinsert(2) = 0
    AddText "AutoCAD 2004", ptinsert, 5
    ptinsert(0) = 100: ptinsert(1) = 110: ptinsert(2) = 0
    AddMtext ptinsert, 30, "VBA 程序设计"
    ptinsert(0) = 100: ptinsert(1) = 120: ptinsert(2) = 0
    AddTextHA "清华大学出版社", ptinsert, 5, 0.4
    ptinsert(0) = 100: ptinsert(1) = 140: ptinsert(2) = 0
    AddMtextHA ptinsert, 50, "明经通道欢迎你", 5, 0.4
    ZoomExtents
    End Sub

    代码完。

    ”明经通道欢迎你“没有显示出来,提示438错误“对象不支持该属性或方法”。

    作者:codee
    文章千古事,得失寸心知。


  • 相关阅读:
    Thinking Clearly about Performance
    国家统计局2018-10-30统计的最新的省市区
    Java 返回字符串中第一个不重复字符的下标 下标从0开始
    国际象棋的游戏规则
    Python语言之requests库
    VBS 自动发消息给对方
    Windows
    上海合计共有16个区一个县
    @RequestMapping中的注解
    Linux 中 /proc/kcore为啥如此之大
  • 原文地址:https://www.cnblogs.com/bimgoo/p/2502917.html
Copyright © 2020-2023  润新知