ACAD200 to ACAD2004 Migration of VB Code

Discussion in 'AutoCAD' started by bsande1, Sep 10, 2004.

  1. bsande1

    bsande1 Guest

    Hello,

    I'm up the proverbial creek, and I don't have a paddle, I don't even have a boat.

    I work for a large mid-western company. We've been using ACAD2000 for years. I am a power user, but we had a gentleman that wrote about a dozen standalone VB programs for us. These have been real time savers.

    Well, he retired, and my boss told me that I would be taking over for him. I haven't been offered any training, just sort of thrown into the deep end. I've been able to keep my head above water, but now he wants to upgrade to 2004.

    I've started upgrading our customizations. Everything works (menus, LISP, etc.) except the darn VB. If I try to run it in VB, it tells me that "AutoCAD not running!" His code, not VB's.

    This is the code from that section:

    Private Sub Form_Load()
    Dim Ires As Integer
    On Error Resume Next
    Set acadAPP = GetObject(, "AutoCAD.Application")
    If Err Then
    Ires = MsgBox("AutoCAD not running!", vbInformation, "Opps!")
    Err.Clear
    Unload Form1
    Else
    Set acadDOC = acadAPP.ActiveDocument
    Set moSpace = acadDOC.ModelSpace
    'Set initial rotation angle
    rotationAngle = DegreesToRadians#(0#) ' bottom orientation OK
    rotationAngleText = DegreesToRadians#(0#)
    End If
    End Sub

    I know a little about VB. I have been able to update his code as things have gone along. I assume that VB code that runs ACAD2000 should do the same in ACAD2004. I'm hoping that only a line or two of code needs to be changed to let VB recognize ACAD2004. Am I all wet?

    Bill Sander
    Missouri
     
    bsande1, Sep 10, 2004
    #1
  2. Well, wet is a relative term =) Here is your fix however you're still going
    to be wet until you learn how to search the ngs - this question gets
    answered at least once a week and it is documented in the help files:

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 10, 2004
    #2
  3. bsande1

    jay1thes519 Guest

    Besides the other change suggested:
    Set acadAPP = GetObject(, "AutoCAD.Application.16")

    Make sure that you also change the reference to the new version of AutoCAD ... also there is a good help file in the dev help there are some changes between the versions. Some you can ignore for now that won't be an issue until 2005 (such as color) and there also seems to be some places in the VB api that could require some work arounds.

    jason
    www.hmkx.com
     
    jay1thes519, Sep 11, 2004
    #3
  4. bsande1

    manoj_vest Guest

    Hi Bill,

    Since you are using

    Set acadAPP = GetObject(, "AutoCAD.Application")

    to get the AutoCAD object, you don't need to change any thing in your code. Only you need to do is Go to your
    Project>>References and change from "AutoCAD 2000 Type Library" to "AutoCAD 2004 Type Library". If your system does not containg AutoCAD 2000 then you will be getting "AutoCAD 2000 Type Library Missing" so unchech is and look for the "AutoCAD 2004 Type Library" and check is. Build your project and will start working.

    Thanks
    Manoj
     
    manoj_vest, Sep 13, 2004
    #4
  5. Re-read his post. Changing his reference does not change the version of
    AutoCAD he loads. Using Set acadAPP = GetObject(, "AutoCAD.Application")
    will retrieve the last version of AutoCAD started which is NOT neccessarily
    the version he wants started.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 13, 2004
    #5
  6. bsande1

    bsande1 Guest

    Wow, youse guys are great.

    Checked "AutoCAD 2004 Library", and it works like a charm.

    Thanks for the quick response (and for making me look again like a computer-god in my manager's eyes).

    Bill Sander
    Missouri
     
    bsande1, Sep 13, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.