.NET API

BricsCAD (Windows) Pro or higher


 

The BricsCAD .NET API exposes BricsCAD functionality for use by managed plugins based on the .NET Common Language Runtime (CLR) platform. This API is available out of the box, with the managed assemblies included as part of the standard product installation.

Runtime

BricsCAD 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 _AcGbl = Bricscad.Global; //Bricsys specific
  using _AcQad = Bricscad.Quad; //Bricsys specific
  using _AcInt = Bricscad.Internal;
  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 _AcGc = Bricscad.Parametric; //Bricsys specific
  using _AcHlr = Bricscad.Hlr; //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;
  using _AdWnd = Autodesk.Windows;
  using _AcRbn = Autodesk.AutoCAD.Ribbon;
  using _AcInt = Autodesk.AutoCAD.Internal;
  using _AcLy = Autodesk.AutoCAD.LayerManager;
  using _AxApp = Autodesk.AutoCAD.Interop; //COM
  using _AxDb = Autodesk.AutoCAD.Interop.Common; //COM
#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 'Bricsys specific
  Imports _AcGbl = Bricscad.Global 'Bricsys specific
  Imports _AcQad = Bricscad.Quad 'Bricsys specific
  Imports _AcInt = Bricscad.Internal
  Imports _AcPb = Bricscad.Publishing
  Imports _AcMg = Teigha.ModelerGeometry 'Bricsys specific
  Imports _AcLic = Bricscad.Licensing 'Bricsys specific
  Imports _AcMec = Bricscad.MechanicalComponents 'Bricsys specific
  Imports _AcBim = Bricscad.Bim 'Bricsys specific
  Imports _AcDm = Bricscad.DirectModeling 'Bricsys specific
  Imports _AcIfc = Bricscad.Ifc 'Bricsys specific
  Imports _AcRhn = Bricscad.Rhino 'Bricsys specific
  Imports _AcCiv = Bricscad.Civil 'Bricsys specific
  Imports _AcGc = Bricscad.Parametric 'Bricsys specific
  Imports _AcHlr = Bricscad.Hlr 'Bricsys 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
  Imports _AdWnd = Autodesk.Windows
  Imports _AcRbn = Autodesk.AutoCAD.Ribbon
  Imports _AcInt = Autodesk.AutoCAD.Internal
  Imports _AcLy = Autodesk.AutoCAD.LayerManager
  Imports _AxApp = Autodesk.AutoCAD.Interop 'COM
  Imports _AxDb = Autodesk.AutoCAD.Interop.Common 'COM
#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.