20 | 09 | 2017

Start AutoCad Session .NET

 Use the Function below to start a AutoCad session from VB.NET


Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput

   End Class


Public Class Class2

    Public Function StartAutoCADSession() As Object

        '*********Code from VisibleVisual.com*********

        On Error Resume Next

        Dim AcadApp As Object
        'Check if a AutoCad session Exists
        AcadApp = GetObject(, "AutoCAD.Application")
        If Err.Number <> 0Then
            'If there is no AutoCad session active then there will be one created
            AcadApp = CreateObject("AutoCAD.Application")
        End If

        If Err.Number <> 0 Then
            StartAutoCADSession = Nothing
            Exit Function
        End If

        'if successful set visibility status
        AcadApp.Visible = 1
        'opened OK
        Return AcadApp

    End Function


Sign up now and upload your code to the website.

Help us to continue.....
Articles View Hits
Latest Articles