22 | 02 | 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
            Err.Clear()
            '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


Login

Sign up now and upload your code to the website.

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