.NET API

BricsCAD (Windows) Pro or higher


 

The BricsCAD .NET API exposes BricsCAD functionality for use by managed code built on the .NET Common Language Runtime (CLR) platform.

Runtime

BricsCAD V23 uses .NET Framework version 4.8. Visual Studio 2019 or later (including Visual Studio Community Edition) is recommended for .NET plugin development.

Existing modules compiled for older BricsCAD versions should continue to work unless version-dependent P/invoke signatures were used to access unmanaged API functions.

.NET project setup in Visual Studio

Create a class library using the class library wizard under your preferred .NET language. Reference the two required assemblies (BrxMgd.dll and TD_Mgd.dll). Reference the optional BREP API (TD_MgdBrep.dll) and/or 2d constraints API (TD_MgdDbConstraints.dll) if needed. These DLLs are located in your BricsCAD installation folder.

Sample projects are installed along with BricsCAD in subfolder \API\dotNet.

Code compatibility

It is generally possible to use the same source code to build assemblies targeting both BricsCAD and AutoCAD. A common technique for resolving differences in namespaces is to use short namespace aliases that resolve differently depending on the target application platform:

C#
VB.NET

#if BRX_APP
  using _AcAp = Bricscad.ApplicationServices;
  using _AcBr = Teigha.BoundaryRepresentation;
  using _AcCm = Teigha.Colors;
  using _AcDb = Teigha.DatabaseServices;
  using _AcEd = Bricscad.EditorInput;
  using _AcGe = Teigha.Geometry;
  using _AcGi = Teigha.GraphicsInterface;
  using _AcGs = Teigha.GraphicsSystem;
  using _AcGsk = Bricscad.GraphicsSystem;
  using _AcPl = Bricscad.PlottingServices;
  using _AcBrx = Bricscad.Runtime;
  using _AcTrx = Teigha.Runtime;
  using _AcWnd = Bricscad.Windows;
  using _AdWnd = Bricscad.Windows;
  using _AcRbn = Bricscad.Ribbon;
  using _AcLy = Teigha.LayerManager;
  using _AcIo = Teigha.Export_Import; //Bricsys specific
  using _AcBgl = Bricscad.Global; //Bricsys specific
  using _AcQad = Bricscad.Quad; //Bricsys specific
  using _AcInt = Bricscad.Internal;
  using _AcPm = Bricscad.Parametric; //Bricsys specific
  using _AcPb = Bricscad.Publishing;
  using _AcMg = Teigha.ModelerGeometry; //Bricsys specific
  using _AcLic = Bricscad.Licensing; //Bricsys specific
  using _AcMec = Bricscad.MechanicalComponents; //Bricsys specific
  using _AcBim = Bricscad.Bim; //Bricsys specific
  using _AcDm = Bricscad.DirectModeling; //Bricsys specific
  using _AcIfc = Bricscad.Ifc; //Bricsys specific
  using _AcRhn = Bricscad.Rhino; //Bricsys specific
  using _AcCiv = Bricscad.Civil; //Bricsys specific
  using _AxApp = BricscadApp; //COM
  using _AxDb = BricscadDb; //COM
#elif ARX_APP
  using _AcAp = Autodesk.AutoCAD.ApplicationServices;
  using _AcBr = Autodesk.AutoCAD.BoundaryRepresentation;
  using _AcCm = Autodesk.AutoCAD.Colors;
  using _AcDb = Autodesk.AutoCAD.DatabaseServices;
  using _AcEd = Autodesk.AutoCAD.EditorInput;
  using _AcGe = Autodesk.AutoCAD.Geometry;
  using _AcGi = Autodesk.AutoCAD.GraphicsInterface;
  using _AcGs = Autodesk.AutoCAD.GraphicsSystem;
  using _AcGsk = Autodesk.AutoCAD.GraphicsSystem;
  using _AcPl = Autodesk.AutoCAD.PlottingServices;
  using _AcPb = Autodesk.AutoCAD.Publishing;
  using _AcBrx = Autodesk.AutoCAD.Runtime;
  using _AcTrx = Autodesk.AutoCAD.Runtime;
  using _AcWnd = Autodesk.AutoCAD.Windows; //AcWindows.dll
  using _AdWnd = Autodesk.Windows; //AdWindows.dll
  using _AcRbn = Autodesk.AutoCAD.Ribbon; //AcWindows.dll
  using _AcInt = Autodesk.AutoCAD.Internal;
  using _AcLy = Autodesk.AutoCAD.LayerManager;
  using _AxApp = Autodesk.AutoCAD.Interop;
  using _AxDb = Autodesk.AutoCAD.Interop.Common;
#endif

#If BRX_APP Then
  Imports _AcAp = Bricscad.ApplicationServices
  Imports _AcBr = Teigha.BoundaryRepresentation
  Imports _AcCm = Teigha.Colors
  Imports _AcDb = Teigha.DatabaseServices
  Imports _AcEd = Bricscad.EditorInput
  Imports _AcGe = Teigha.Geometry
  Imports _AcGi = Teigha.GraphicsInterface
  Imports _AcGs = Teigha.GraphicsSystem
  Imports _AcGsk = Bricscad.GraphicsSystem
  Imports _AcPl = Bricscad.PlottingServices
  Imports _AcBrx = Bricscad.Runtime
  Imports _AcTrx = Teigha.Runtime
  Imports _AcWnd = Bricscad.Windows
  Imports _AdWnd = Bricscad.Windows
  Imports _AcRbn = Bricscad.Ribbon
  Imports _AcLy = Teigha.LayerManager
  Imports _AcIo = Teigha.Export_Import 'BricsCAD specific
  Imports _AcBgl = Bricscad.Global 'BricsCAD specific
  Imports _AcQad = Bricscad.Quad 'BricsCAD specific
  Imports _AcInt = Bricscad.Internal
  Imports _AcPm = Bricscad.Parametric 'BricsCAD specific
  Imports _AcPb = Bricscad.Publishing
  Imports _AcMg = Teigha.ModelerGeometry 'BricsCAD specific
  Imports _AcLic = Bricscad.Licensing 'BricsCAD specific
  Imports _AcMec = Bricscad.MechanicalComponents 'BricsCAD specific
  Imports _AcBim = Bricscad.Bim 'BricsCAD specific
  Imports _AcDm = Bricscad.DirectModeling 'BricsCAD specific
  Imports _AcIfc = Bricscad.Ifc 'BricsCAD specific
  Imports _AcRhn = Bricscad.Rhino 'BricsCAD specific
  Imports _AcCiv = Bricscad.Civil 'BricsCAD specific
  Imports _AxApp = BricscadApp 'COM
  Imports _AxDb = BricscadDb 'COM
#ElseIf ARX_APP Then
  Imports _AcAp = Autodesk.AutoCAD.ApplicationServices
  Imports _AcBr = Autodesk.AutoCAD.BoundaryRepresentation
  Imports _AcCm = Autodesk.AutoCAD.Colors
  Imports _AcDb = Autodesk.AutoCAD.DatabaseServices
  Imports _AcEd = Autodesk.AutoCAD.EditorInput
  Imports _AcGe = Autodesk.AutoCAD.Geometry
  Imports _AcGi = Autodesk.AutoCAD.GraphicsInterface
  Imports _AcGs = Autodesk.AutoCAD.GraphicsSystem
  Imports _AcGsk = Autodesk.AutoCAD.GraphicsSystem
  Imports _AcPl = Autodesk.AutoCAD.PlottingServices
  Imports _AcPb = Autodesk.AutoCAD.Publishing
  Imports _AcBrx = Autodesk.AutoCAD.Runtime
  Imports _AcTrx = Autodesk.AutoCAD.Runtime
  Imports _AcWnd = Autodesk.AutoCAD.Windows 'AcWindows.dll
  Imports _AdWnd = Autodesk.Windows 'AdWindows.dll
  Imports _AcRbn = Autodesk.AutoCAD.Ribbon 'AcWindows.dll
  Imports _AcInt = Autodesk.AutoCAD.Internal
  Imports _AcLy = Autodesk.AutoCAD.LayerManager
  Imports _AxApp = Autodesk.AutoCAD.Interop
  Imports _AxDb = Autodesk.AutoCAD.Interop.Common
#End If

Known issues

After creating a new database entity, it is good practice to immediately call SetDatabaseDefaults() on the new entity so that it has valid initial state before setting properties or calling methods.

 


© Bricsys NV. All rights reserved.