Loading multiple linetypes into AutoCAD using .NET


Loading multiple linetypes into AutoCAD using .NET

https://www.keanw.com/2010/03/loading-mult ... to-autocad-using-net.html


程序代码:

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Namespace LoadLinetypes
    Public Class Commands
        <CommandMethod("LL")> _
        Public Sub LoadLinetypes()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
            Const  filename As String = "acad.lin"
            Try
                Dim path As String = HostApplicationServices.Current.FindFile(filename, db, FindFileHint.[Default])
                db.LoadLineTypeFile("*", path)
            Catch ex As Autodesk.AutoCAD.Runtime.Exception
                If ex.ErrorStatus = ErrorStatus.FilerError Then
                    ed.WriteMessage(vbLf & "Could not find file ""{0}"".", filename)
                ElseIf ex.ErrorStatus = ErrorStatus.DuplicateRecordName Then
                    ed.WriteMessage(vbLf & "Cannot load already defined linetypes.")
                Else
                    ed.WriteMessage(vbLf & "Exception: {0}", ex.Message)
                End If
            End Try
        End Sub
    End Class
End Namespace




eDuplicateRecordName



欢迎关注微信公众账号ByCAD