GeometryHelper.CadConvert 13.1.0

dotnet add package GeometryHelper.CadConvert --version 13.1.0
                    
NuGet\Install-Package GeometryHelper.CadConvert -Version 13.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="13.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GeometryHelper.CadConvert" Version="13.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 13.1.0
                    
#r "nuget: GeometryHelper.CadConvert, 13.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@13.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=13.1.0
                    
Install as a Cake Addin
#tool nuget:?package=GeometryHelper.CadConvert&version=13.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, Ray and Xline entities, polylines and polygons with the arcs their bulges draw, arcs, circles, ellipses, splines, 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.

Ellipses

An AutoCAD Ellipse is held as a centre, a normal, a major axis as long as the major radius, and the ratio of the minor radius to the major one, which is what a GeoEllipse3 holds, so it reads and writes exactly.

GeoEllipse3 real = acadEllipse.ToGeoEllipse3();         // in its own plane
GeoEllipse2 flat = acadEllipse.ToGeoEllipse2();         // as it is seen in plan
acadEllipse.TryToGeoEllipse2(out GeoEllipse2 read);     // false rather than throwing

Ellipse drawn = real.ToAcadEllipse();                   // a whole turn, 0 to 2π
Ellipse drawnFlat = flat.ToAcadEllipse();               // in the XY plane

GeometryHelper has no elliptical arc, so an Ellipse entity that sweeps less than a whole turn is refused with an ArgumentException rather than closed up. Reading in plan throws an InvalidOperationException for an ellipse standing square to the XY plane, which would flatten into a segment.

A Circle tilted out of the plan is an ellipse in plan, and ToGeoEllipse2 reads it as one: a circle of radius 300 tilted 60° from the plan is an ellipse 300 by 150. ToGeoCircle2 keeps only its centre and radius, and a tilted Arc is still refused by ToGeoArc2, since in plan it is an elliptical arc.

GeoEllipse2 outline = tiltedCircle.ToGeoEllipse2();
tiltedCircle.TryToGeoEllipse2(out GeoEllipse2 seen);   // false when it stands square to XY

Rays and infinite lines

An AutoCAD Ray and Xline are each held as a base point and a unit direction, which is what a GeoRay3 and a GeoXLine3 hold, so they convert with nothing lost; the direction is made unit length again on reading, so it can differ in its last digit after a round trip, and an entity whose direction has no length is refused with an ArgumentException. A ray runs for ever from its base point, an Xline for ever both ways.

GeoRay3 ray = acadRay.ToGeoRay3();
GeoXLine3 axis = acadXline.ToGeoXLine3();

Ray drawnRay = ray.ToAcadRay();
Xline drawnAxis = axis.ToAcadXline();

// In the plan: lay the line out in a frame, here the world's.
GeoXLine2 inPlan = axis.ProjectToXLine2(GeoCoordinateSystem3.Global);

A default ray or line, which has no direction, is refused with an ArgumentException on its way to AutoCAD, which has no entity for it.

These conversions are checked to compile and are untested at run time: AutoCAD's entities cannot be made outside AutoCAD.

Splines

An AutoCAD Spline holds a NURBS curve, read through its NurbsData: a degree, control points, knots and, where it is rational, weights, which is what a GeoSpline3 holds, kept as given, so its numbers pass over as they are, both ways. A spline AutoCAD made from fit points is read by the control points AutoCAD keeps for it; the fit points themselves are not carried.

GeoSpline3 real = acadSpline.ToGeoSpline3();         // in space, as AutoCAD holds it
GeoSpline2 flat = acadSpline.ToGeoSpline2();         // as it is seen in plan
acadSpline.TryToGeoSpline2(out GeoSpline2 read);     // false rather than throwing

Spline drawn = real.ToAcadSpline();                  // not periodic, its tolerances 1E-10
Spline drawnFlat = flat.ToAcadSpline();              // in the XY plane

GeometryHelper's splines are clamped: they start at their first control point and end at their last. A periodic Spline, which is how AutoCAD closes a spline smoothly, is refused with an ArgumentException rather than reshaped, and so is one GeometryHelper cannot hold (a degree above 10 throws an ArgumentOutOfRangeException). Reading in plan is exact, a NURBS seen square onto a plane being the NURBS of its control points seen so, so a tilted spline, or one that bends out of a plane, is read as its outline in plan; it throws an InvalidOperationException only where it stands square to the XY plane and every control point lands on one point. A spline written to AutoCAD is told it is closed only where its first and last control points are the same point exactly, as they are for a circle FromCircle builds; ends that are only near do not make it closed.

These conversions too are checked to compile and are untested at run time, AutoCAD's entities not being made outside AutoCAD: whether AutoCAD reads a clamped spline it is told is closed as anything more than a flag is not known here.

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
13.1.0 39 10/29/2026
13.0.0 49 10/28/2026
12.3.0 89 10/23/2026
12.2.0 94 10/14/2026
12.1.0 93 10/12/2026
12.0.0 92 10/7/2026
11.2.0 96 10/6/2026
11.1.0 91 10/6/2026
11.0.1 99 10/5/2026
11.0.0 101 10/5/2026
10.0.0 93 10/3/2026
9.0.2 100 10/1/2026
9.0.1 93 10/1/2026
9.0.0 102 10/1/2026
8.0.0 94 9/30/2026
7.0.0 95 9/29/2026
6.3.0 101 9/29/2026
6.2.0 95 9/29/2026
6.1.0 95 9/28/2026
6.0.0 94 9/28/2026
Loading failed

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,
     ellipses, rays, xlines, splines, and Extents2d/Extents3d as rectangles.

     ARCS READ AS DRAWN (13.0.0)
     - ToGeoArc2 and ToGeoArc3 read an Arc through its ends and its middle at a tolerance of nought, as AutoCAD drew
       it. GeometryHelper 13.0.0 reads three points within the tolerance of one line as a line, so the arc of radius
       1 000 sweeping 0.002 radians, its middle 0.0005 off its chord of 2, would have been refused at the global
       tolerance; it comes through as it did.

     RAYS, LINES AND SPLINES (12.3.0)
     - RayConvert and XlineConvert read the Ray and Xline entities as GeoRay3 and GeoXLine3 and write them
       back; SplineConvert reads a Spline as GeoSpline3, or as GeoSpline2 where it lies in plan
       (TryToGeoSpline2 reports false instead of throwing), and ToAcadSpline writes either back.

     ELLIPSES (12.1.0)
     - The Ellipse entity converts both ways: ToGeoEllipse3 reads it in its own plane, ToGeoEllipse2
       reads it as seen in plan (TryToGeoEllipse2 reports false instead of throwing), and
       ToAcadEllipse writes a GeoEllipse3 or GeoEllipse2 back as a whole turn. An elliptical arc is
       refused, since GeometryHelper has none.
     - ToGeoEllipse2 also reads a Circle as it is seen in plan, a tilted one included: a circle of
       radius 300 tilted 60 degrees from the plan is an ellipse 300 by 150.

     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.