×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Autocad + Visual Basic 6

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!

RE: Autocad + Visual Basic 6

If that's all you want to do then I suggest you look at creating a DDE connection between your VB programme and AutoCAD and then use sendkeys from VB to AutoCAD to open the drawing and draw the line.

RE: Autocad + Visual Basic 6

(OP)
When i said that this is all what I need to know, is because with a line I have a start point to continue with my project. My problem is to start it. I don`t want to do this with sendkeys, because i know that autocad as vba, and with that my programm will have a better performance.

Thanks anyway.

RE: Autocad + Visual Basic 6

Sorry, I'm a bit confused here?
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

Hi...

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

(OP)
Tnanks a lot to everyone. That really helps to clarify the ideas.

RE: Autocad + Visual Basic 6

Thanks Speed.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources