Autocad + Visual Basic 6
Autocad + Visual Basic 6
(OP)
Hello
I have read the focus, and i have not found what I need.
All I want is to open a drawing from VB6 (by a command button), and draw a line from 2 points that were specified in the visual basic 6 aplication.
Can someone tell me the code that I need please.
(My proyect has the autocad library, all I need is know how to open an autocad file and draw the line)
Very simple!
I have read the focus, and i have not found what I need.
All I want is to open a drawing from VB6 (by a command button), and draw a line from 2 points that were specified in the visual basic 6 aplication.
Can someone tell me the code that I need please.
(My proyect has the autocad library, all I need is know how to open an autocad file and draw the line)
Very simple!





RE: Autocad + Visual Basic 6
RE: Autocad + Visual Basic 6
Thanks anyway.
RE: Autocad + Visual Basic 6
Are you opening an existing drawing or starting a new drawing?
Are you using Visual Basic or AutoCAD's inbuilt Visual Basic for Applications?
RE: Autocad + Visual Basic 6
First, in Visual Basic 6.0 You must go to the menu Project->References..
Second, you must found the AutoCAD 2000 Type Library and select it and press To Accept.
Third, in the section of Declarations you must declare the variable that represents the application of AutoCAD and other that represents the utility of AutoCAD. For example:
Options Explicit
Private autocadApp As AcadApplication
Private utilGet As AcadUtility
Quarter, in the Load event of the Form you must make the reference to variable. For example:
Private Sub Form_Load()
On Error Resume Next
Set autocadApp = GetObject(, "AutoCAD.Application.15")
Set utilGet = autocadApp.ActiveDocument.Utility
If Err Then
Err.Clear
Set autocadApp = CreateObject("AutoCAD.Application.15")
Set utilGet = autocadApp.ActiveDocument.Utility
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
End Sub
Fifth, in a CommandButton you must do the following thing:
Private Sub Command1_Click()
Form1.Hide
Dim Distance As Double
AppActivate autocadApp.Caption
Distance = utilGet.GetDistance(, vbCr & "Specify first point: ")
Form1.Show
MsgBox Distance, vbInformation, "Example"
End Sub
To open a drawing you must make this:
First declare a variable type Document, next open the drawing:
Dim doc As AcadDocument
Set doc = autocadApp.Application.Documents.Open("c:\drawing.dwg")
I hope that it serves to him
RE: Autocad + Visual Basic 6
RE: Autocad + Visual Basic 6