GstarCAD 2022 Visual Basic Development Guide

Contents

9cb00a228b5f15c7cb6d32ac

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…]

d1a163cf39a6683b15b4e7da

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).

Note

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".

493bdd4f09816b48bf29d550