ActiveTextStyle 示例

使用 VBA 以外的其它编程语言

Sub Example_ActiveTextStyle()
    ' 本示例返回当前文字样式,然后设置一个新的样式。
    ' 最后,它返回先前的样式。
    Dim newTextStyle As AcadTextStyle
    Dim currTextStyle As AcadTextStyle
    
    ' 返回活动文档的当前文字样式
    Set currTextStyle = ThisDrawing.ActiveTextStyle
    MsgBox "当前文字样式为 " & currTextStyle.name, vbInformation, "ActiveTextStyle 示例"
    
    ' 创建一个文字样式并设为当前样式
    Set newTextStyle = ThisDrawing.TextStyles.Add("TestTextStyle")
    ThisDrawing.ActiveTextStyle = newTextStyle
    MsgBox "新的文字样式为 " & newTextStyle.name, vbInformation, "ActiveTextStyle 示例"
    
    ' 重设文字样式为先前设置
    ThisDrawing.ActiveTextStyle = currTextStyle
    MsgBox "文字样式重设为 " & currTextStyle.name, vbInformation, "ActiveTextStyle 示例"
End Sub