Modifying AutoCAD support Path through .NET



Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports System.Reflection
Imports Autodesk.AutoCAD.EditorInput

Public Class test
    <CommandMethod("AddSupportPath")> _
    Public Shared Sub AddSupportPath()
        Dim acadObject As Object = Application.AcadApplication
        Dim preferences As Object = acadObject.[GetType]().InvokeMember("Preferences", BindingFlags.GetProperty, Nothing, acadObject, Nothing)
        'get the files
        Dim files As Object = preferences.[GetType]().InvokeMember("Files", BindingFlags.GetProperty, Nothing, preferences, Nothing)
        'get the support path SupportPath
        Dim supportPath As String = CType(files.[GetType]().InvokeMember("SupportPath", BindingFlags.GetProperty, Nothing, files, Nothing), String)
        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        If Not supportPath.Contains("C:\BatchPublish") Then
            supportPath = supportPath + ";" + "C:\BatchPublish"
            Dim dataArry As Object() = New Object(0) {}
            dataArry(0) = supportPath
            files.[GetType]().InvokeMember("SupportPath", BindingFlags.SetProperty, Nothing, files, dataArry)
            ed.WriteMessage(supportPath + vbLf)
        Else
            ed.WriteMessage("Support path already present" & vbLf)
        End If
    End Sub

End Class

http://adndevblog.typepad.com/autocad/2012/05/ ... upport-path-through-net.html



为Document.BeginDwgOpen注册事件



欢迎关注微信公众账号ByCAD