GstarCAD 2024 VBA Migration Guide

Contents

Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/b19c2b093d11ba271a676cb5

1. Migrate Project Code

1.1. Run AutoCAD® VBA Manager

Run VBAMAN command to launch the VBA Manager in AutoCAD® as shown below.

Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/0403a680157d3e111459309d

1.2. Load Project File (.dvb) to Be Migrated

Click Load… and select the DVB file to load, e.g. 'v baSample.dvb ' as shown below:

Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/7c6088e31acc4e338ef07e8e

1.3. Run VBA Editor

Click Visual Basic Editor button to launch VBA editor and all the project contents of ' vbaSample.dvb ' are listed

on the left side of the VBA editor, and the project name is 'MySection '.

Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/a36a339407105721f49ccab2

1.4. Export VBA Project

  1. Right click on the items under Forms , Modules or Class Modules , e.g. right click on the ' frmAbout ' form under Forms and select Export File…, as shown below:
Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/f4db12d3d824ced4a38a3f5c
  1. Specify a folder to save the exported file (The extension of exported form file is '. frm ').

  2. In the same way, export modules and class modules to files (The extension of exported module is ' .bas ', and the extension of exported class module is ' .cls ').

  3. Double click on ' ThisDrawing ' under AutoCAD Objects to show and copy the codes to a new file.

1.5. Run VBA Editor in GstarCAD

Run VBAIDE command to launch the VBA editor in GstarCAD, same as that of AutoCAD. A new empty project

' GCADProject ' is automatically created by default.

Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/9b945030c91f14d875b33602

1.6. Modify Project Name

Right click on the ' GCADProject ' and select GCADProject Properties(E)… , the Project Properties dialog window pops out. Modify the Project Name to ' MySection ' as same name as that in AutoCAD, and click OK .

Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/6fed6160ecd49c9d915eb173 Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/46f022ecce0230353793f3b2 Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/af0a26c8b83dbaeaf273eb67

7

1.7. Import File

  1. Right click on 'MySection ' project and select the Import File… The Import File dialog window pops out, as shown below.
Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/84745fa9399ca3dbd935a5e3
  1. Select all files just exported from AutoCAD and import into ' MySection ' project, as shown below:
Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/0e64fe41174318c0c70b5c26 Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/851942ed9bd604b70cc3127c

1.8. Import Code of ' ThisDrawing '

Copy the source codes exported from ' ThisDrawing ' in AutoCAD to ' ThisDrawing ' here in GstarCAD VBA editor.

Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/44ddba207a4dddb3af9f7b17

1.9. Save as GstarCAD VBA Project (.vbi)

Click File → Save to save ' MySection ' project as ' vbaSample.vbi ', as shown below:

Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/3ea6b822f2ba5cf146af08f0 Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/601b213cce9d8c8286d5045d
NOTE

The extension name of AutoCAD VBA project file is ' DVB ' while the extension name of GstarCAD VBA project file is ' VBI '.

2. Modify Migrated Code

  1. Replace the preifx ' Acad ' of COM object name used in migrated codes with ' Gcad ' in correspondance with GstarCAD, e.g. replace " AcadLine " with " GcadLine ".

  2. Replace the ' autocad. a pplication ' used in migrated codes with ' gcad.application ' in correspondance with GstarCAD.

Copyright reserved: Gstarsoft Co.,Ltd

Copying and referencing any part of this document is allowed. No part of this document may be changed

without permission. Please keep this statement when copying or referencing this document.

Literature/GSTARCAD/2024/03 API Guides/assets/VBA Migration Guide assets/27495333982dd41eb80446ac