GeometryHelper.CadConvert 5.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package GeometryHelper.CadConvert --version 5.1.0
                    
NuGet\Install-Package GeometryHelper.CadConvert -Version 5.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GeometryHelper.CadConvert" Version="5.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GeometryHelper.CadConvert" Version="5.1.0" />
                    
Directory.Packages.props
<PackageReference Include="GeometryHelper.CadConvert" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GeometryHelper.CadConvert --version 5.1.0
                    
#r "nuget: GeometryHelper.CadConvert, 5.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GeometryHelper.CadConvert@5.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GeometryHelper.CadConvert&version=5.1.0
                    
Install as a Cake Addin
#tool nuget:?package=GeometryHelper.CadConvert&version=5.1.0
                    
Install as a Cake Tool

GeometryHelper.CadConvert

NuGet Version License: MIT

Converts geometry between AutoCAD and GeometryHelper, both ways: points, vectors, line segments and Line entities, polylines and polygons with the arcs their bulges draw, arcs, circles, and Extents2d/Extents3d as rectangles.

Installation

dotnet add package GeometryHelper.CadConvert

You must add the AutoCAD assemblies yourself

This package does not contain any AutoCAD assembly. They are Autodesk's to distribute rather than ours, so it ships only its own code and leaves those references to you. Until you add them, code that touches this library fails to compile with CS0012: the type is defined in an assembly that is not referenced.

The library itself resolves against acdbmgd.dll alone — that is where Point3d, Polyline, Circle, Line and Extents3d live. A plugin normally also wants acmgd.dll and accoremgd.dll for the editor and application APIs, so all three are shown below.

Take them from either source:

From your AutoCAD installation — the usual choice, because it guarantees you build against the same version you run:

<Reference Include="accoremgd">
  <HintPath>C:\Program Files\Autodesk\AutoCAD 2024\accoremgd.dll</HintPath>
  <Private>false</Private>
</Reference>
<Reference Include="acdbmgd">
  <HintPath>C:\Program Files\Autodesk\AutoCAD 2024\acdbmgd.dll</HintPath>
  <Private>false</Private>
</Reference>
<Reference Include="acmgd">
  <HintPath>C:\Program Files\Autodesk\AutoCAD 2024\acmgd.dll</HintPath>
  <Private>false</Private>
</Reference>

Or from Autodesk's own package on nuget.org:

dotnet add package AutoCAD.NET

Keep Copy Local false. AutoCAD supplies those assemblies at run time from its own installation, and a copy sitting next to your plugin risks loading a build that does not match the running AutoCAD.

Which AutoCAD version

The package is built against the AutoCAD 2024 API (assembly version 24.0.0.0). Autodesk keeps the Autodesk.AutoCAD.Geometry and Autodesk.AutoCAD.DatabaseServices types this library touches stable across releases, so building from source against another version needs no source changes.

AutoCAD.NET on nuget.org carries no netstandard2.0 assets — version 24–25 ship net47 and version 26 ships net10.0 — so a project taking that dependency has to target the framework matching the AutoCAD it runs in. Referencing the DLLs directly, as above, avoids that constraint.

Usage

using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using GeometryHelper.CadConvert;
using GeometryHelper.Geometry;

// AutoCAD to GeometryHelper
GeoPoint2 point = new Point3d(100, 200, 0).ToGeoPoint2();
GeoPolyline2 path = acadPolyline.ToGeoPolyline2();
GeoRectangle2 bounds = extents.ToGeoRectangle2();
GeoCircle2 circle = acadCircle.ToGeoCircle2();

// GeometryHelper back to AutoCAD
Polyline drawn = path.ToAcadPolyline();
Line drawnLine = geoLine.ToAcadLine();
Point3d back = point.ToAcadPoint3();

Point chains

EnumerableExtension covers the step before a polyline exists: a raw list of points read out of a drawing, usually carrying more of them than the geometry needs.

// Drop points that sit within the tolerance of the point kept before them.
List<Point3d> thinned = points.RemoveConsecutiveNearPoints(0.5);

// One segment per consecutive pair; the chain is left open.
List<LineSegment3d> segments = thinned.ToLineSegments3d();

LineSegment3d longest = segments.GetLongestLength();

RemoveConsecutiveNearPoints compares each point against the last one kept, not against its original neighbour, which is what guarantees no two points of the result are within the tolerance of each other. The first point always survives; the last one is not privileged, so re-append it yourself when the endpoint matters.

Arcs and bulges

An AutoCAD polyline carries a bulge against each vertex, and a vertex with a bulge is joined to the next one by an arc. Reading such a polyline as points alone used to straighten it silently, so a slot came back a rectangle. It no longer does.

// Keeps every arc: the bulge AutoCAD stores is the bulge GeometryHelper stores.
GeoPolylineArc2 chain = acadPolyline.ToGeoPolylineArc2();
GeoPolygonArc2 loop   = acadPolyline.ToGeoPolygonArc2();

// Cuts the arcs into straight pieces, within 0.2 % of each radius, and says so in GeometryHelperLog.
GeoPolyline2 path = acadPolyline.ToGeoPolyline2();
GeoPolygon2 area  = acadPolyline.ToGeoPolygon2(0.05);   // or name the chord tolerance yourself

// Refuses rather than approximates, for a caller that needs the shape exactly.
if (acadPolyline.TryToGeoPolygon2(out GeoPolygon2 exact)) { ... }

// And back, bulge for bulge; the loop comes back closed.
Polyline drawnChain = chain.ToAcadPolyline();
Polyline drawnLoop  = loop.ToAcadPolyline();

ToGeoPolyline2 and ToGeoPolygon2 still return the straight types they always did, so nothing that used them has to change — they now trace the arc instead of cutting across it. Work on the shape with the whole of GeometryHelper, then write it back:

GeoPolygonArc2 rounded = acadPolyline.ToGeoPolygonArc2().Fillet(25.0);
acadPolyline.Erase();
blockTable.AppendEntity(rounded.ToAcadPolyline());

The Arc and Circle entities convert on their own too:

GeoArc2 flat = acadArc.ToGeoArc2();     // in plan; throws if the arc is tilted out of XY
GeoArc3 real = acadArc.ToGeoArc3();     // whatever plane it lies in
acadArc.TryToGeoArc2(out GeoArc2 read); // false rather than throwing

Arc drawn = flat.ToAcadArc();
Circle hole = new GeoCircle2(center, 12.5).ToAcadCircle();

An AutoCAD arc always sweeps counter-clockwise about its normal and has nowhere to put a direction of its own, so a clockwise GeoArc2 is written with its two angles exchanged: the same curve, read back counter-clockwise.

Licence

MIT. The AutoCAD assemblies this library compiles against are covered by Autodesk's own licence terms, not by this one.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.2 34 10/1/2026
9.0.1 30 10/1/2026
9.0.0 37 10/1/2026
8.0.0 38 9/30/2026
7.0.0 66 9/29/2026
6.3.0 71 9/29/2026
6.2.0 63 9/29/2026
6.1.0 78 9/28/2026
6.0.0 78 9/28/2026
5.1.0 97 9/21/2026
5.0.0 89 9/21/2026
4.0.0 94 9/18/2026
3.2.0 98 9/17/2026
3.1.0 106 8/28/2026
3.0.2 115 8/23/2026
3.0.0 119 8/23/2026

Converts geometry between AutoCAD and GeometryHelper, both ways: points, vectors, line segments
     and Line entities, polylines and polygons with the arcs their bulges draw, arcs, circles, and
     Extents2d/Extents3d as rectangles.

     ARCS AND BULGES
     - An AutoCAD polyline carries a bulge against each vertex, and a vertex with a bulge is joined to
       the next one by an arc. Reading such a polyline as points alone straightened it silently, so a
       slot came back a rectangle. It no longer does.
     - ToGeoPolylineArc2 and ToGeoPolygonArc2 read one bulge for bulge into the chains GeometryHelper
       5.0 added, losing nothing, and ToAcadPolyline writes either of them back the same way, so the
       round trip is exact.
     - ToGeoPolyline2 and ToGeoPolygon2 still return the straight types they always did, so nothing
       that used them has to change; they now trace each arc with straight pieces within 0.2 % of its
       radius instead of cutting across it, and say in GeometryHelperLog how many they cut. An overload
       takes the chord tolerance when that is not fine enough, and TryToGeoPolyline2 and
       TryToGeoPolygon2 report false rather than approximate anything.
     - ToAcadPolyline on a GeoPolygon2 writes a closed polyline; it had no way to say so before.
     - The Arc and Circle entities convert on their own: ToGeoArc2 reads an arc in plan and refuses one
       tilted out of XY, TryToGeoArc2 reports false instead, ToGeoArc3 reads any arc in its own plane,
       and ToGeoCircle3 keeps the plane a circle lies in. ToAcadArc and ToAcadCircle write them back.
       An AutoCAD arc always sweeps counter-clockwise about its normal and has nowhere to put a
       direction of its own, so a clockwise arc is written with its two angles exchanged: the same
       curve, read back counter-clockwise.
     - These need GeometryHelper 5.0 or later.

     REQUIRES AUTOCAD ASSEMBLIES YOU MUST SUPPLY
     - No AutoCAD assembly is redistributed here, because they are Autodesk's to ship rather than
       ours. Reference them yourself, either from your AutoCAD installation folder or from Autodesk's
       own AutoCAD.NET package on nuget.org. Without them the compiler reports CS0012.
     - This library resolves against acdbmgd.dll alone; a plugin normally also wants acmgd.dll and
       accoremgd.dll for the editor and application APIs.
     - Reference them with Copy Local set to false. AutoCAD supplies them at run time from its own
       installation, and a copy sitting next to your plugin risks loading a build that does not match
       the running AutoCAD.
     - This package is built against the AutoCAD 2024 API (assembly version 24.0.0.0).

     EXTENSIONS
     - GeometryHelper.CadConvert also carries EnumerableExtension: chaining a list of Point2d or
       Point3d into segments, thinning a chain of points by a tolerance, and picking the longest
       segment out of a list.