Hi,
Thanks for your reply.
I want to open an already existing drawing from AutoCAD through VB and also i want to create a new drawing in AutoCAD when AutoCAD is invoked through VB(ie the file name and path will be specified in VB and the AutoCAD drawing should be saved in that path and name accordingly.If possible,can you send me the codings appropriate for this.
This is something I have used to connect to ACAD. There is an option to connect to an existing session. It uses a global to set AutoCAD.app to that global...
Function OpenAcadApp(Optional bAcVisiblity As Boolean = True, _
Optional bConnectToExisting As Boolean = False) 'As AcadApplication
'------------------------------------------------------------------------------
'OpenAcadApp: Establish a connection to Autocad or create one if none exists
'Arguments: Visibility: default True
' Connect to running session - default FALSE
'Issues: "Asks for FONTALT"
'------------------------------------------------------------------------------
Dim iCnt As Integer: iCnt = 0
'Dim objAcadApp As AcadApplication
If bConnectToExisting = True Then
On Error Resume Next
Set objAcadApp = GetObject(, "AutoCAD.Application"
Select Case Err.Number
Case 429 'Autocad not started already
Err.Clear
GoTo Restart
Case 0 'AutoCad already running
Exit Function
End Select
End If
Restart:
Set objAcadApp = CreateObject("AutoCAD.Application"
If Err.Number = 91 Then
Err.Clear
If iCnt = 3 Then
Exit Function
Else
GoTo Restart
iCnt = iCnt + 1
End If
Else
Err.Clear
End If
'--------------------------------------------------------------------------
'Set the Visibility option
'--------------------------------------------------------------------------
objAcadApp.Visible = bAcVisiblity
'Set OpenAcadApp = objAcadApp
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.