GstarCAD 2027 VBA Migration Guide
GstarCAD 2027 VBA Migration Guide
Contents
Migrate Project Code
Run AutoCAD® VBA Manager
Run VBAMAN command to launch the VBA Manager in AutoCAD® as shown below.
Load Project File (.dvb) to Be Migrated
Click Load… and select the DVB file to load, e.g. 'vbaSample.dvb' as shown below:
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'.
Export VBA Project
- 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:
-
Specify a folder to save the exported file (The extension of exported form file is '.frm').
-
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').
-
Double click on 'ThisDrawing' under AutoCAD Objects to show and copy the codes to a new file.
Run VBA Editor in GCAD
Run VBAIDE command to launch the VBA editor in GCAD, same as that of AutoCAD. A new empty project 'GCADProject' is automatically created by default.
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.
Import File
- Right click on 'MySection' project and select the Import File… The Import File dialog window pops out, as shown below.
- Select all files just exported from AutoCAD and import into 'MySection' project, as shown below:
Import Code of 'ThisDrawing'
Copy the source codes exported from 'ThisDrawing' in AutoCAD to 'ThisDrawing' here in GCAD VBA editor.
Save as GCAD VBA Project (.vbi)
Click File→Save to save 'MySection' project as 'vbaSample.vbi', as shown below:
The extension name of AutoCAD VBA project file is 'DVB' while the extension name of GCAD VBA project file is 'VBI'.
Modify Migrated Code
-
Replace the preifx 'Acad' of COM object name used in migrated codes with 'Gcad' in correspondance with GCAD, e.g. replace "AcadLine" with "GcadLine".
-
Replace the 'autocad.application' used in migrated codes with 'gcad.application' in correspondance with GCAD.
Copyright
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.
