.NET
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
With BricsCAD V19, the supported .NET
framework version is 4.5.1 (CLR version 4).
The .NET 4.5.1 framework is
highly compatible with .NET Framework 4. Existing modules compiled
for older BricsCAD versions should work in V19 unless
version-dependent P/invoke signatures were used to access unmanaged
API functions.
Compiler version
For new development on V20,
developers must use Visual Studio 2017 or later. Managed modules
compiled with .NET 4 for older BricsCAD versions will continue to
run on V19 but Visual Studio 2010 and older versions of VS will not
recognize the current BrxMgd TD_Mgd modules because they are based
on .NET 4.5.1.
For .NET based development it is
sufficient to use the free Visual Studio Community
Edition.
.NET project setup in Visual
Studio
Create a class library using the class
library wizard under your preferred .NET language. There are
currently two DLLs that must be referenced (BrxMgd.dll and TD_Mgd.dll) plus one optional BREP API DLL
(TD_MgdBrep.dll). These DLLs are located
in your BricsCAD installation folder.
Important note: when referencing
these DLLs, it's important to set the 'Copy
Local' property to False.
Note: importing the BricsCAD and
Teigha COM type libraries requires TlbImp without the /strictref option!
Sample projects can be found in
the BricsCAD install folder, subfolder
\API\dotNet.
Bricscad.Internal
Since V18, the
Bricscad.Internal namespace has been added, with plans to add
undocumented functions upon request.
Changes in V20
BRX18.DLL has been
updated as BRX19.DLL, P/Invoke signatures depending on this file
will need to be updated accordingly.
Code
compatibility
It's 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
are different depending on the target
application:
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 _AcInt = Bricscad.Internal;
#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 _AcBrx = Autodesk.AutoCAD.Runtime;
using _AcTrx = Autodesk.AutoCAD.Runtime;
using _AcWnd = Autodesk.AutoCAD.Windows;
using _AcInt = Autodesk.AutoCAD.Internal;
#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 _AcInt = Bricscad.Internal
#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 _AcBrx = Autodesk.AutoCAD.Runtime
Imports _AcTrx = Autodesk.AutoCAD.Runtime
Imports _AcWnd = Autodesk.AutoCAD.Windows
Imports _AcInt = Autodesk.AutoCAD.Internal
#End If
|
Known
differences
There are some known
differences that developers should be aware
of.
Access DBObject after transaction
ends
In AutoCAD, objects
belonging to a transaction remain accessible in some cases even
after the transaction has ended. In BricsCAD, all transaction
resident objects are closed when the transaction ends. For
example:
using (_AcDb.Transaction tr =
db.TransactionManager.StartTransaction())
{
_AcDb.DBObject space = tr.GetObject(db.CurrentSpaceId,
_AcDb.OpenMode.ForRead);
tr.Commit();
//now 'space' is closed and no longer transaction
resident
_AcDb.ObjectId idXDict = space.ExtensionDictionary;
//works in Acad; eInvalidOperation in Teigha
}
If this situation is
encountered, there are two common solutions:
- Reorder the
sequence of events so that all object access is completed before
the transaction ends.
- Use
OpenCloseTransaction for object access, either exclusively or to
access an object after the transaction has
ended.
|
© Bricsys NV. All rights reserved. |