GstarCAD 2022 Visual Basic Development Guide
GstarCAD 2022 Visual Basic Development Guide
Contents
1. Overview
Using VB to develop GstarCAD is essentially an application development based on the COM interface provided by GstarCAD, which is popular and easy to use.
2. Create Visual Basic Project
Create a new Visual Basic project, and then add a reference
Select menu [project] > [Reference…]
Click the [Browse] button and select the corresponding gcax.tlb file in grxsdk\inc-x86, which is under the GRX installation directory (if you are using the 64-bit GstarCAD, please select the corresponding file in grxsdk\inc-x64).
Please use “Run as administrator” option to start Visual Basic.
3. Get GCAD application
Please use following code to get GCAD Application objects:
On Error Resume Next
Set GCADapp = GetObject(, "gcad.application")
If Err Then
Set GCADapp = CreateObject("gcad.application")
GCADapp.WindowState = acMax
End If
4. Visual Basic Migration
To migrate the code from AutoCAD to GstarCAD platform, you need to replace the names of some COM objects which used in AutoCAD with the corresponding COM object names in GstarCAD platform. Such as "AcadLWPolyline", you need to replace its prefix "Acad" with "Gcad". The right one should be "GcadLWPolyline".
