Migrating AutoCAD® .NET Classic Application to ARES Commander

You can migrate .NET applications running on AutoCAD® platform to ARES Commander with minimal changes using following 2 steps.

  • Replace AutoCAD® .NET assemblies with ARES .NET assemblies into your project references.

  • Replace Autodesk.AutoCAD namespace with Teigha namespace in the source code.

Equivalent Assemblies and Namespaces

  • Assemblies

AutoCAD®

ARES Commander

AutoCAD®

ARES Commander

acmgd.dll + accoremgd.dll + accui.dll

FxCoreMgd_*.dll

acdbmgd.dll

TD_Mgd_*.dll

  • Namespaces - Most commonly used namespaces mapped as below

AutoCAD® Namespace

ARES Commander Namespace

AutoCAD® Namespace

ARES Commander Namespace

Autodesk.AutoCAD.ApplicationServices

Teigha.ApplicationServices

Autodesk.AutoCAD.ApplicationServices.Core

Teigha.ApplicationServices.Core

Autodesk.AutoCAD.EditorInput

Teigha.EditorInput

Autodesk.AutoCAD.Runtime

Teigha.Runtime

Autodesk.AutoCAD.DatabaseServices

Teigha.DatabaseServices

Autodesk.AutoCAD.Geometry

Teigha.Geometry

Autodesk.AutoCAD.PlottingServices

Teigha.PlottingServices

Autodesk.AutoCAD.Colors

Teigha.Colors

Autodesk.AutoCAD.Customization

Teigha.Customization

Autodesk.AutoCAD.Windows

Teigha.Windows

Autodesk.AutoCAD.GraphicsSystem

Teigha.GraphicsSystem

Only Global namespace are different in AutoCAD®[Autodesk.AutoCAD] and in ARES[Teigha] rest internal namespaces names are same and classes and methods are fully compatible.

Advance Migration

If you do not want to maintain separate source code for AutoCAD® and ARES Commander, then additional steps are necessary. A single project with two build configuration solves the issue.

Step 1: Create 2 new build configurations for one for AutoCAD® and another for ARES Commander.

 

Step 2: Using project Properties, select all configurations one by one and define Symbol “AutoCAD” or “ARES” for the corresponding configurations.

For AutoCAD_Release configuration:

 

For ARES_Release:

 

 Step 3: Add Conditional reference assemblies to the project using Symbols. Modify csproj file manually in the text editor to add condition for all references as in the following example.



<ItemGroup>       <Reference Include="accoremgd" Condition="$(DefineConstants.Contains('AutoCAD'))">         <HintPath>C:\Program Files\Autodesk\AutoCAD 2020\accoremgd.dll</HintPath>       </Reference>       <Reference Include="acdbmgd" Condition="$(DefineConstants.Contains('AutoCAD'))">         <HintPath>C:\Program Files\Autodesk\AutoCAD 2020\acdbmgd.dll</HintPath>       </Reference>       <Reference Include="acmgd" Condition="$(DefineConstants.Contains('AutoCAD'))">         <HintPath>C:\Program Files\Autodesk\AutoCAD 2020\acmgd.dll</HintPath>       </Reference>       <Reference Include="FxCoreMgd_4.03_15" Condition="$(DefineConstants.Contains('ARES'))">         <HintPath>C:\Program Files\Graebert GmbH\ARES Commander 2020\BIN\FxCoreMgd_4.03_15.dll</HintPath>       </Reference>       <Reference Include="TD_Mgd_4.03_15" Condition="$(DefineConstants.Contains('ARES'))">         <HintPath>C:\Program Files\Graebert GmbH\ARES Commander 2020\BIN\TD_Mgd_4.03_15.dll</HintPath>       </Reference>     </ItemGroup>

Step 4: Change in the source code add using directives for both SDK conditionally and also alias the Global namespace of both CAD Libraries to CADLib as below and Replace Autodesk.AutoCAD to  this new alias CADLib in *.cs source files. One has to do this for each cs file in the project which is using APIs belongs to Autodesk.AutoCAD because using directive is limited to a single cs file.

 

#if  ARES   using Teigha.DatabaseServices;   using Teigha.Runtime;   using Teigha.Geometry;   using Teigha.ApplicationServices;   using Teigha.EditorInput;   using CADLib = Teigha;   #elif  AutoCAD   using Autodesk.AutoCAD.DatabaseServices;   using Autodesk.AutoCAD.Runtime;   using Autodesk.AutoCAD.Geometry;   using Autodesk.AutoCAD.ApplicationServices;   using Autodesk.AutoCAD.EditorInput;   using CADLib = Autodesk.AutoCAD;   #endif   //If we already aliased Autodesk.AutoCAD or Teigha to CADLib by using statement as above then to migrate below statement //where we have used fully qualified calss name as Color below Autodesk.AutoCAD.Colors.Color acadColor = Autodesk.AutoCAD.Colors.Color.FromRgb(color.R, color.G, color.B); //migrated code will be and will work for both .NET SDK   CADLib.Colors.Color acadColor = CADLib.Colors.Color.FromRgb(color.R, color.G, color.B); //Such situation only happens when Color conflicts with Other namespace's Color class //then we have to write fully qualified class name.

Step 5:

Specify separate Output folders for both configurations.

Build both configurations one by one. The builds will work with their corresponding applications.