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.

Ā