ActiveLinetype 示例

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

Sub Example_ActiveLinetype()
    ' 本示例查找当前线型。它然后设置新的线型为线型集合中与当前线型不同的第一个线型。
    ' 最后,它重设活动的线型为原设置值。
    
    Dim currLineType As AcadLineType
    Dim newLineType As AcadLineType
    
    ' 查找活动文档的当前线型
    Set currLineType = ThisDrawing.ActiveLinetype
    MsgBox "当前线型为 " & currLineType.name, vbInformation, "ActiveLinetype 示例"
    
    ' 设置当前线型为集合中任何一个
    Dim entry
    Dim found As Boolean
    For Each entry In ThisDrawing.Linetypes
        If StrComp(entry.name, currLineType.name, 1) <> 0 Then
            Set newLineType = entry
            found = True
            Exit For
        End If
    Next
    If found Then
        ThisDrawing.ActiveLinetype = newLineType
        MsgBox "新的线型为 " & newLineType.name, vbInformation, "ActiveLinetype 示例"
        ' 重设线型为先前设置
        ThisDrawing.ActiveLinetype = currLineType
        MsgBox "活动线型重设为 " & currLineType.name, vbInformation, "ActiveLinetype 示例"
    End If
End Sub