1 / 21

AutoCAD® VBA to .NET Migration: The Easy Way Using COM Interop

AutoCAD® VBA to .NET Migration: The Easy Way Using COM Interop. Augusto Gonçalves Developer Consultant at Autodesk. Meet the presenter. Augusto Gonçalves Developer Technical Services São Paulo, Brazil Autodesk

shina
Download Presentation

AutoCAD® VBA to .NET Migration: The Easy Way Using COM Interop

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AutoCAD® VBA to .NET Migration: The Easy Way Using COM Interop Augusto Gonçalves Developer Consultant at Autodesk

  2. Meet the presenter Augusto GonçalvesDeveloperTechnicalServicesSão Paulo, BrazilAutodesk Augusto is member of DevTech team since 2008 based at São Paulo office. He is specialist in AutoCAD, Civil3D and Revit APIs. Before join Autodesk, Augusto worked on CAD-related developments for civil engineering and web commerce. He is graduated in Civil Engineering and holds a Master in Computer Engineer.

  3. Autodesk Developer Network • Access to almost all Autodesk software and SDK’s • Including early access to Beta software • Members-only website with 1000s of technical articles • Unlimited technical support • Product direction through conferences • Marketing benefits • Exposure on autodesk.com • Promotional opportunities • 1 to 3 free API training classes • Based on user level www.autodesk.com/joinadn

  4. Agenda

  5. Why migrate to VB.NET? • Discontinuation of the VBA Licensing Program • We do not expect to be included with AutoCAD for many releases • Limitations • VBA 32 bits running on 64 bits • No 64 bits of many features, such as DAO • New .NET technologies • True Object Orientation • WinForms, ADO.NET, AutoCAD.NET

  6. The ActiveX API • ActiveX is the API used by VBA • The discontinuation announced by Microsoft do not apply to the API, only to the IDE • You can use this API from .NET • .NET Interop can access the same object model available on VBA

  7. VBA vs. VB.NET comparison

  8. The new IDE: Visual Studio • Succeeds VBAIDE • There are many versions, including a free version - Express

  9. Demonstration • Creating a simple Hello World with VB.NET using COM Interop • Goals • Understand type of project, references and required code

  10. Migration step-by-step • Prepare your code for migration • May reduce the required effort and improve the final result • Export your VBA project to VB6 • Save each VBA file, such as modules, classes and userforms • Import into a VB6 project • Append all files exported from VBA • Upgrade using Visual Basic Express • This is the migration itself • Make some corrections • Such as references and ThisDrawing variable

  11. Prepare you code for migration • Use Early-Binding instead Late-Binding • Consider replace all Object and Variant • Use CXxxx where relevant • Cint, CStr, CDbl, etc

  12. Demonstration • Perform the step-by-step migration for a simple project • Will not include UserForms

  13. Using the converter Macro • Create a VB6 project from a VBA .dvb file • Do not require VB6 installed • Convert UserForms into Forms • Which allow migration to .NET WinForms • Automate steps 3 and 4 (export from VBA to VB6) • Save us a lot of manual work

  14. Demonstration • Using the converter macro

  15. Working with events • Use a ThisDrawing variable instead a property • WithEvents keyword cannot be applied to properties • Manage swap between documents • This is automatically on VBA, but VB.NET requires a special code • Start handling events on startup

  16. Demonstration • Special requirements to handle ThisDrawing events

  17. Demonstration • Particularities when handling Form events • Goal • Understand how manually check and correct migrated events

  18. Quick throubleshooting • Some common issues when migrating from VBA to VB.NET • You may check it when you start your work • Unable to cast COM object exception • Requires a later version of the .NET Framework • Project cannot be started directly

  19. Additional Resources Through the Interface blog • http://through-the-interface.typepad.com AutoCAD.NET Developer’s Guide • http://www.autodesk.com/autocad-net-developers-guide ADN DevTV: AutoCAD VBA to .NET Migration Basics • http://download.autodesk.com/media/adn/VBA_Migration/DevTV_Recording.zip Discussion Groups • http://discussion.autodesk.com/forums/category.jspa?categoryID=8 Autodesk Developer Network • http://www.autodesk.com/joinadn

  20. DevLab • San Francisco, USA Feb 1-5, 2010 • Farnborough, UK Feb 8-12, 2010 • Munich, Germany June 7-11, 2010 • Other countries TBD • www.autodesk.com/apitraining > Schedule • stephen.preston@autodesk.com

More Related