×
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

VB6 and AutoCad (dsi ..do reply)

VB6 and AutoCad (dsi ..do reply)

VB6 and AutoCad (dsi ..do reply)

(OP)
I asked about generating visual effects in other programming languages through autocad, which dsi mentioned that VB6 can be of help. I have actually made a program of Stiffness Matrix in Fortran , but am not satisfied with the presentation, im looking forward to make it in VB , if any one can help me in mentioning the sources from where i can get hints about working in Autocad and VB6 together.

RE: VB6 and AutoCad (dsi ..do reply)

The first step would be to learn the AutoCAD VBA. Once you learn how to do stuff there, you can easily do it in VB6. You just have to include the AutoCAD Object Library in your project references.

There is a ton of information in the AutoCAD help files on VBA. Go to Help > Contents and see the chapter on ActiveX and VBA.

There is also a good book that covers this topic pretty well. AutoCAD 2000 VBA by Joe Sutphin. I found it for less than $30.

I am still unsure of excatly what you want to accomplish. If you want, you can send me some screen captures of your existing Fortran results. If they will help, I can link them into this thread so others can view them as well.

Here is a quick sample on how to use VB6 to automate AutoCAD

Sub Test()
    Dim CadApp As AcadApplication
    Dim CadDwg As AcadDocument
    Dim textObj As AcadText

    Dim pt2(0 To 2) As Double

    '<><><><><><><><><><><><><><><><><><><><><>
    '  Connect to AutoCAD
    '<><><><><><><><><><><><><><><><><><><><><>
    On Error Resume Next
    Set CadApp = GetObject(, "AutoCAD.Application")
    If Err.Number <> 0 Then     'Not Running
        Set CadApp = CreateObject("AutoCAD.Application")
        Err.Clear
    End If
    On Error GoTo ErrHndlr

    '<><><><><><><><><><><><><><><><><><><><><>
    '  Open the Drawing Template
    '<><><><><><><><><><><><><><><><><><><><><>
    sDwgTemplate = "C:\Temp\A5-Template.dwg"
    If Dir(sDwgTemplate) <> "" Then
        CadApp.Documents.Open sDwgTemplate
    Else
        MsgBox "File " & sDwgTemplate & " does not exist."
    End If

    '<><><><><><><><><><><><><><><><><><><><><>
    '  Update Drawing
    '<><><><><><><><><><><><><><><><><><><><><>
    Set CadDwg = CadApp.ActiveDocument

    pt2(x) = 8.6422:    pt2(y) = 7.1831:    pt2(z) = 0

    'Insert 1/8" text at pt 2
    Set textObj = CadDwg.ModelSpace.AddText("Test", pt2, 0.125)

    CadApp.ZoomExtents
'    CadDwg.SaveAs ("FullPath and New File Name Here")


CleanUp:
    Set CadDwg = Nothing
    Set CadApp = Nothing
    Set textObj = Nothing
    Exit Sub
ErrHndlr:
    CadApp.Visible = False
    MsgBox "Error in Test()" & vbCrLf & vbCrLf & _
           "Error No. " & Err.Number & vbCrLf & _
           "Description: " & Err.Description
    Err.Clear
    CadApp.Visible = True
End Sub

I hope that works! I quickly scammed a couple of lines from one of my applications.

As you can see, it is not too difficult. Hope this helps!

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