Difference between VBA and VB.Net?

Discussion in 'AutoCAD' started by sbrusco, Jan 31, 2005.

  1. sbrusco

    sbrusco Guest

    Hi All,

    I have a simple question that may take more than a simple answer. What is the difference between programming for AutoCAD in VBA and in VB.Net?

    I have done a fair amount of programming in VL and i'm starting to work in VBA, and today my IS department has given me a gift of an unopened VB.Net (Standard) package.

    Should i use this or continue to work with the VBA that comes with AutoCAD? Advantages? Disadvantages? I don't even know what questions to ask? What is this '.net' environment?

    TIA,
    Sal
     
    sbrusco, Jan 31, 2005
    #1
  2. AutoCAD VBA is accessible only from a running instance of AutoCAD while
    ..NET is a standalone environment. Grossly oversimplifying, .NET is far
    more capable than VBA but it's also more complex. Thanks to the new,
    native .NET APIs for AutoCAD, .NET also enjoys better access to
    AutoCAD's drawing databases.
     
    Frank Oquendo, Jan 31, 2005
    #2
  3. sbrusco

    sbrusco Guest

    Thanks Frank,

    If i can press you to further elaborate, what do you mean by 'more capable' and 'better access to AutoCAD's drawing databases'?

    I have heard about the 'more complex' issue, but was told it would be a long time, if ever, before .net replaced VBA. What is your take on this?

    Since i'm only getting started with VBA in Acad and could go either way at this point, do you have any recommendations or suggestions? I have written VB stand-alones but nothing in VBA.

    Sal
     
    sbrusco, Feb 3, 2005
    #3
  4. Hi Sal,

    I would say the only advantage of VBA is sample code, help files and a
    higher level of expertise in the NG to help you.

    The decision is mostly a psychological one - do you enjoy being at the
    cutting edge or not?

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au

    capable' and 'better access to AutoCAD's drawing databases'?
    long time, if ever, before .net replaced VBA. What is your take on this?
    this point, do you have any recommendations or suggestions? I have written
    VB stand-alones but nothing in VBA.
     
    Laurie Comerford, Feb 3, 2005
    #4
  5. Like all .NET languages, VB.NET has a wealth of ready-to-use code in the
    form of the .NET framework so you spend the bulk of your time leveraging
    that functionality rather than writing it.

    As for better access to AutoCAD, the managed libraries are thin wrappers
    around a subset of the ObjectARX API so you can do things not available
    to VB or VBA programmers.
    VBA will be with us for quite some time, yes. However, in and of itself,
    that means very little. That's like saying DOS is still around. While
    true, that does not speak to whether your needs can be met with a
    particular set of tools.
    If you know VB, you know VBA. I guess what it boils down to is the kind
    of work you'll be doing. If it's all macros, VBA is more than
    sufficient. When it comes to working with technologies like data access,
    XML and web services (to name a few), VB.NET is a far better choice.
    Especially when you consider it can do everything VBA can do.
     
    Frank Oquendo, Feb 4, 2005
    #5
  6. sbrusco

    FrozenLips Guest

    Though I am very familiar with both - VBA and VB.NET, I never worked with VB.NET in an AutoCAD context.

    Just out of curiosity,
    How is it done?
     
    FrozenLips, Feb 5, 2005
    #6
  7. The COM model is still the same but you have to deal with interop issues
    like marshaling and casting.

    The new managed libraries offer additional tools primarily aimed at
    drawing database manipulation.
     
    Frank Oquendo, Feb 5, 2005
    #7
  8. sbrusco

    sbrusco Guest

    Hi Frank,

    Thanks again for taking the time to elaborate. As always, your experience and knowledge are only exceeded by your willingness to help others. And speaking for 'other', we appreciate it.

    Sal
     
    sbrusco, Feb 8, 2005
    #8
  9. sbrusco

    Matt Howland Guest

    Net is not fully supported by AutoCAD. I am designing a program to work with Architectural desktop using vb.net and have had some problems from time to time. There is one part of the program that I had to do in VBA and then execute from my program. There are definite advantages working with vb.net, but I have also found some major problems to work through.

    I found that it is better to use the type objects that start with "I" most of the time. They do not work when you are trying to run events off an AutoCAD object, but they best when trying to change properties of objects, particularly w/ Architectural Desktop. For example instead of using AcadLine I use IAcadLine. The "I" stands for an interface object.

    I hope this has been helpful
     
    Matt Howland, Feb 8, 2005
    #9
  10. Matt,
    What were you able to accomplish with VBA that you couldn't accomplish with
    VB.NET? Just curious. Thanks.
    --
    Bobby C. Jones

    with Architectural desktop using vb.net and have had some problems from time
    to time. There is one part of the program that I had to do in VBA and then
    execute from my program. There are definite advantages working with vb.net,
    but I have also found some major problems to work through.
    of the time. They do not work when you are trying to run events off an
    AutoCAD object, but they best when trying to change properties of objects,
    particularly w/ Architectural Desktop. For example instead of using
    AcadLine I use IAcadLine. The "I" stands for an interface object.
     
    Bobby C. Jones, Feb 8, 2005
    #10
  11. sbrusco

    Matt Howland Guest

    Anchoring a door to a wall in architectural desktop 2004. Here is the code:

    Dim Drawing As AcadDocument
    Set Drawing = Application.ActiveDocument
    Dim Door As AcadObject
    Dim Anchor As New AecAnchorOpeningBaseToWall

    Dim tempob As AcadSelectionSet
    Set tempob = Drawing.SelectionSets.Item("Openingtemp")
    Dim walltemp As AecWall
    Set walltemp = tempob.Item(0)
    Set Door = tempob.Item(1)
    Drawing.SelectionSets.Item("Openingtemp").Delete
    Anchor.Reference = walltemp
    Door.AttachAnchor Anchor

    In VB.net you cannot get AecAnchorOpeningBaseToWall to initialize properly. Every time you set the anchor.reference it comes up w/ saying "Reference not set to an instance of an object". If you use IAecAnchorOpeningBaseToWall (the interface object), you cannot call the New on it, so it doesn't initialize properly. If anyone has come up with a way to do it in VB.net, I would love to hear about it.

    Matt
     
    Matt Howland, Feb 14, 2005
    #11
  12. Concrete classes typically have a name in the form <interface>Class. If
    the Aec object library follows the same convention, something like this
    might work:

    Dim Anchor As IAecAnchorOpeningBaseToWall = New
    AecAnchorOpeningBaseToWallClass();
     
    Frank Oquendo, Feb 14, 2005
    #12
  13. sbrusco

    Matt Howland Guest

    If you are still interested in this topic, I wanted to let you know that I tried that and it didn't work. Thank you for the tip though because I have found it usefull in other situations. If you have anything else that would be helpful, I would appreciate it. Thanks again.
     
    Matt Howland, Mar 22, 2005
    #13
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.