| Set AutoCad Reference |
|
|
|
| Tutorials | |||
|
If you are familiar with AutoCad VBA then its a small step to start programming Visual Basic 6.0. You only need to set the reference to the AutoCad type library:
With this done VB 6.0 is now equiped with the same library as AutoCad VBA. Now it's possible to create the Thisdrawing statement from which we can start giving commands to AutoCad Public ThisDrawing As AcadDocument
Public Connect2AutoCad()
'****************************************
'*** Code from VisibleVisual.com ********
'**************************************** Dim Acad As AcadApplication
On Error Resume Next
'Check if AutoCad is open
Set Acad = GetObject(, "AutoCAD.Application")
If Err Then
MsgBox "Autocad Application is Not Open"
Err.Clear
Exit Sub
'Attempt to open AutoCad
Set Acad = CreateObject("AutoCAD.Application")
'AutoCAD isn't available
If Err Then
MsgBox "Can't start AutoCAD!", vbExclamation, "Error loading AutoCAD"
End If
End If
Set ThisDrawing = objAcad.ActiveDocument
Acad.Visible = True
End Sub
Now you can use the Thisdrawing statement in Visual Basic 6.0 the same as you would have done in VBA
|



