Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AutoCAD Connection

Status
Not open for further replies.

latha2k1

Programmer
Feb 1, 2003
17
IN
Hi,
How to trap AutoCAD 2000 drawings in Visual Basic
Thankyou
saradha

 
Are you referring to opening a drawing or getting the active drawing? Is this VBA or VB?
 
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.

Iam badly in need of this
thankyou
latha
 
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
 
if u want i can send u the program....just give me ur email address


...JarJar...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top