GstarCAD 2027 .NET Migration Guide

Contents

fe0efab3f8d0e37e84d756ee

Introduction

There are a large number of .NET applications based on AutoCAD®. It is easy to migrate .NET application programs with little change to the original source codes, keeping the source-code-level compatibility.

Programming Environment

  • Microsoft® Visual Studio 2022 (version 17.8.0)

  • Windows SDK 10.0 (latest installed version)

  • CPU:

Basic: 1.6 GHz CPU

Recommended: 3.0 GHz CPU and above

  • RAM:

Basic: 2 GB

Recommended: 8 GB and above

  • Operation System (OS)

Windows 11

Windows 10 (version 1507 and above):

Home, Professional, Education and Enterprise (not support LTSC and Windows 10 S)

  • Monitor Resolution:

1028x800 and above true color display, including 4K (3840x2160) display

  • GRXSDK

  • Microsoft .NET 8.0

Requirement on Original Source Code

The original source codes should be .NET application source codes of .NET ObjectARX 2025.

Install SDK

Download SDK.

Unzip GRXSDK.ZIP file to the local disk (e.g. 'C:\grxsdk') and there will be 5 directories generated (in 'C:\grxsdk') which are: arx, inc, inc-x64, lib-x64 and utils.

arx contains the header files, library files and sample programs used for porting ARX programs to GRX programs. It contains the following directories:

  • Inc: Header files used for porting from ARX to GRX

  • inc-x64: Files used by COM and .NET (for 64-bit)

  • lib-x64: GRX libraries (for 64-bit)

  • Samples: Sample projects, including Dotnet, fact_dg, HelloADS, HelloARX and SimplePalette.

  • Dotnet: .NET programming samples

  1. Addline: .NET programming sample of adding solid lines

  2. Hello: .NET programming sample of outputting prompt information

  3. Vbhello: Sample of .NET programming with VB .NET

  • fact_dg: Sample of LISP function definition

  • HelloADS: Sample of ADS programming

  • HelloARX: Sample of GRX programming

  • SimplePalette: Programming sample of how to create a set Palette windows

  • Utils: Directory contains sub-directories of GRX extended applications, including APIs for extended function development, e.g. BREP for boundary representation.

Inc: Header files used for programming the GRX

inc-x64: Files used by COM and .NET (for 64-bit)

lib-x64: GRX libraries (for 64-bit)

Utils: Directory contains subdirectories of GRX extended applications, including APIs for extended function development, e.g. BREP for boundary representation.

Visual Studio 2022 C# .NET Program Migration Process

The following illustrates the migration process by taking the 'Hello' project as an example, and assumes that the SDK is installed in 'C:\grxsdk'.

Change Reference File

Remove Reference

From Solution Explorer of Visual Studio 2022, find project 'Hello' and remove relevant ARX reference files, as shown below.

19f6a55d47e7357f9a0824e4

Add Reference

In Solution Explorer of Visual Studio 2022, right-click on project 'Hello' and select Add Reference. After the Reference Manager dialog window pops out, click Browse… button as shown below.

515bf2cf6c7bec82cf289634 8de075eff488713ea3f307fc

Load Reference File

From the installation path of SDK, e.g. 'C:\grxsdk', select 'GcCoreMgd.dll', 'GcDbMgd.dll' and 'GcMgd.dll' in '\arx\inc' and 'GrxCAD.Interop.dll' or 'acax.tlb' in '\arx\inc-x64', and add them by clicking Add button.

f8a59340b559afdd7c552bce Literature/GSTARCAD/2027/03 API Guides/assets/NET Migration Guide assets/de183d7c8e24d0bd96591c75 fef6244e700ae90017225ba3
NOTE

'GcCoreMgd.dll', 'GcDbMgd.dll' and 'GcMgd.dll' must be added while 'GrxCAD.Interop.dll' (or 'acax.tlb') is optional (needed when COM is used in the program).

After adding the files, right-click added 'GcCoreMgd.dll', 'GcDbMgd.dll' and 'GcMgd.dll' files and select Properties at the context menu, the Reference Properties palette pops up. Set the value of Copy Local property to False. The following screenshot shows how to change Copy Local property of 'GcCoreMgd.dll'.

aade68ffd42d1c3810fb5878 3baeb3dde135e46cba4174e4

Modify Name in Namespace

Replace the 'Autodesk.AutoCAD' with corresponding 'Gssoft.Gscad' in .NET source codes.

05656396395af688d0e64f90

Compile Program

In Visual Studio 2022, click Build→Build Solution to regenerate the DLL file in corresponding directory. Run CAD and input 'netload' at command line, select the relative DLL file from Select .Net Assembly dialog window and click Open button to load it.

Visual Studio 2022 VB .NET Program Migration Process

The following illustrates the migration process by taking the 'vbHello' project as an example, and assumes that the SDK is installed in 'C:\grxsdk'.

Change Reference File (2)

Remove Reference (2)

From Solution Explorer of Visual Studio 2022, find project 'vbHello' and remove relevant ARX reference files, as shown below.

7fcbe5a0cb50ce79ba3f79dc

Add Reference (2)

In Solution Explorer of Visual Studio 2022, right-click on project 'vbHello' and select Add Reference. After the Reference Manager dialog window pops out, click Browse… button as shown below.

e89d29025ffbd19ba2fce9b8 5196472d49cce6d3605bbfab

Load Reference File (2)

From the installation path of SDK, e.g. 'C:\grxsdk', select 'GcCoreMgd.dll', 'GcDbMgd.dll' and 'GcMgd.dll' in '\arx\inc' and 'GrxCAD.Interop.dll' or 'acax.tlb' in '\arx\inc-x64', and add them by clicking Add button.

7e691eff72a08753c0f549ed 8fc8d3d9f06b44f43f44bf66
NOTE

'GcCoreMgd.dll', 'GcDbMgd.dll' and 'GcMgd.dll' must be added while 'GrxCAD.Interop.dll' (or 'acax.tlb') is optional (needed when COM is used in the program).

After adding the files, right-click added 'GcCoreMgd.dll', 'GcDbMgd.dll' and 'GcMgd.dll' files and select Properties at the context menu, the Reference Properties palette pops up. Set the value of Copy Local property to False. The following screenshot shows how to change Copy Local property of 'GcCoreMgd.dll'.

9479957b3afe050ba6ecfb7e ae9bfb93e5455519673ed34e

Modify Name in Namespace (2)

Replace the 'Autodesk.AutoCAD' with corresponding 'Gssoft.Gscad' in .NET source codes.

166c492ff2b48e87c9dcc5ee

Compile Program (2)

In Visual Studio 2022, click Build→Build Solution to regenerate the DLL file in corresponding directory. Run CAD and input 'netload' at command line, select the relative DLL file from Select .Net Assembly dialog window and click Open button to load it.

Other Usage

Abtain GCAD Application Object under Visual Basic Environment

By adding 'C:\grxsdk\arx\inc-x64\acax.tlb' as reference, it is possible to obtain GCAD application objects with following codes.

Imports Gssoft.Gscad.Runtime
Imports GCAD
Public Class Class1
    <CommandMethod("GetGcadApplication")>
    Public Sub GetGcadApplication()
'Define abtain GcadApplication object, the object is null
Dim GCadApp As GcadApplication
' Abtain the object address through the process name.
GCadApp = GetObject(, "gcad.application")
'Minimize the abtained process window
        GCadApp.WindowState = GcWindowState.acMin
    End Sub
End Class

C# .NET and VB .NET Namespace Modification

  • VB .NET:

Change 'Autodesk.AutoCAD' to 'Gssoft.Gscad' after the 'Imports'

  • C# .NET:

Change 'Autodesk.AutoCAD' to 'Gssoft.Gscad' after the 'using'

  • COM With VB .NET:

Add 'Imports GCAD' and delete 'Autodesk.AutoCAD.Interop.Common'

  • COM With C# .NET:

Add 'using GCAD' and delete 'Autodesk.AutoCAD.Interop.Common'

For the COM object name in the codes, such as AcadLWPolyline, it is needed to change the prefix 'Acad' to 'Gcad', e.g. 'AcadLWPolyline' should be change to 'GcadLWPolyline'.

If it's not sure a COM object exists or not, then first check it from the object browser, e.g. for ACAD_COLOR, check whether there is corresponding GCAD_COLOR first from the browser. Then change 'ACAD_COLOR' to 'GCAD_COLOR' if GCAD_COLOR is found.

Sample of Replacement

Sample of Namespace Replacement

AutoCAD®GsCAD
Autodesk.AutoCAD.ApplicationServicesGssoft.Gscad.ApplicationServices
Autodesk.AutoCAD.EditorInputGssoft.Gscad.EditorInput
Autodesk.AutoCAD.GraphicsSystemGssoft.Gscad.GraphicsSystem
Autodesk.AutoCAD.PlottingServicesGssoft.Gscad.PlottingServices
Autodesk.AutoCAD.PublishingGssoft.Gscad.Publishing
Autodesk.AutoCAD.RuntimeGssoft.Gscad.Runtime
Autodesk.AutoCAD.WindowsGssoft.Gscad.Windows
Autodesk.AutoCAD.ColorsGssoft.Gscad.Colors
Autodesk.AutoCAD.DatabaseServicesGssoft.Gscad.DatabaseServices
Autodesk.AutoCAD.DatabaseServices.FiltersGssoft.Gscad.DatabaseServices.Filters
Autodesk.AutoCAD.GeometryGssoft.Gscad.Geometry
Autodesk.AutoCAD.GraphicsInterfaceGssoft.Gscad.GraphicsInterface
Autodesk.AutoCAD.LayerManagerGssoft.Gscad.LayerManager

Sample of Class Name and Property Name Replacement

AutoCAD®GsCAD
Autodesk.AutoCAD.Interop.Common.ACAD_COLORGCAD.GCAD_COLOR
Autodesk.AutoCAD.Interop.Common.AcadEntityGCAD.GcadEntity
Autodesk.AutoCAD.Interop.Common.AcSelectGCAD.GcSelect
Autodesk.AutoCAD.Interop.Common.AcadRasterImageGCAD.GcadRasterImage
Autodesk.AutoCAD.Interop.Common.AcadTextGCAD.GcadText
Autodesk.AutoCAD.Interop.Common.AcadMTextGCAD.GcadMText
Autodesk.AutoCAD.Interop.Common.AcWindowStateGCAD.GcWindowState

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.

55d581e92bd5a838526d1e40