GeometryHelper 13.7.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package GeometryHelper --version 13.7.0
                    
NuGet\Install-Package GeometryHelper -Version 13.7.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" Version="13.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GeometryHelper" Version="13.7.0" />
                    
Directory.Packages.props
<PackageReference Include="GeometryHelper" />
                    
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 --version 13.7.0
                    
#r "nuget: GeometryHelper, 13.7.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@13.7.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&version=13.7.0
                    
Install as a Cake Addin
#tool nuget:?package=GeometryHelper&version=13.7.0
                    
Install as a Cake Tool

GeometryHelper

NuGet Version License: MIT

Geometry for engineering drawings and models, in two dimensions and in three, with the label placement that runs on the 2D half. Written in C# and targeting netstandard2.0, so it loads into the .NET Framework hosts that Tekla Structures and AutoCAD provide as well as into modern .NET.

Every comparison that floating point error can affect takes a Tolerance, because coordinates that come out of a BIM model are never exact.

Use the default tolerance. The overloads without a tolerance read Tolerance.Global, which starts as Tolerance.Default: a thousandth of a millimetre for points and for flatness, in a model in millimetres. That is as exact as the corners of a modelled part are: two parts a hundredth apart are apart, and a thin overlap holds what it holds. A finer tolerance cuts as slivers the few ten-thousandths a modeller's rounding leaves faces off flat and parts apart, many times slower; a coarser one, passed to the call that needs it, takes what touches within it for touching. Never new Tolerance(): made so, every threshold is 0. For parts drawn against each other, as a model's are, cut with a SolidBooleanOptions whose Contact takes faces a hundredth apart for touching, and take a part's net body with TrySubtractAll: within a thousandth alone, a part keeps a skin of itself where a cutter's face stood a few thousandths inside it. A body read open, by copies of an edge a hair apart or by a face left out, is closed by TryClose within a gap of its own, a hole filled only where asked, with a report of what it changed or why it would not.

Installation

dotnet add package GeometryHelper

Quick start

using GeometryHelper;            // Tolerance, Angle, OffsetOptions
using GeometryHelper.Enums;      // LineEnd, OffsetJoin, PointLocation
using GeometryHelper.Geometry;   // every Geo type, 2D and 3D
using GeometryHelper.Core;       // every operation

// In the plane: grow a slab, then cut an opening out of it.
var slab = new GeoPolygon2(new GeoPoint2(0, 0), new GeoPoint2(4000, 0),
                           new GeoPoint2(4000, 2000), new GeoPoint2(0, 2000));
var duct = new GeoPolygon2(new GeoPoint2(1000, 500), new GeoPoint2(1400, 500),
                           new GeoPoint2(1400, 900), new GeoPoint2(1000, 900));

GeoPolygon2 grown = slab.Offset(50.0)[0];                 // 4100 x 2100
GeoFace2 pierced = Boolean2.Subtract(grown, duct)[0];     // one face, one hole

// In space: a beam trimmed where it runs into a wall.
var beam = new GeoLine3(new GeoPoint3(0, 0, 0), new GeoPoint3(3000, 0, 0));
var wall = new GeoPlane3(new GeoPoint3(2500, 0, 0), GeoVector3.XAxis);
beam.TryTrimTo(wall, LineEnd.End, out GeoLine3 cut);      // (0,0,0) -> (2500,0,0)

What is inside

Namespace Holds
GeometryHelper Tolerance, Angle, OffsetOptions, GeometryHelperLog, MassProperties3, MeasureComparison3
GeometryHelper.Enums PointLocation, PlaneSide, LineSide, LineEnd, LineExtension, OffsetJoin, VolumeMethod, AreaMethod
GeometryHelper.Geometry 30 immutable shapes: GeoPoint2 … GeoFace2 in the plane, GeoPoint3 … GeoSolid3 in space, arcs and the chains that carry them, and a transformation and a local coordinate system for each dimension
GeometryHelper.Core 35 operation classes, each dimension mirroring the other: Boolean2/Boolean3, Offset2/Offset3, Distance2/Distance3, … plus Arc2, Corner2 for chamfering and rounding, PlanarMap, which carries flat shapes between the two, and Measure3, a body's volume, mass and area read more than one way
GeometryHelper.Spatial GeoBvh2 and GeoBvh3, the bounding volume hierarchies for large chains and meshes
GeometryHelper.Extension turning raw point lists into geometry
GeometryHelper.Arranging label placement: Arranger, ArrangeItem, ArrangeResult, ArrangeOptions, one greedy placement
GeometryHelper.Meshing closed shapes of the plane and flat shapes of space broken into triangles, grids, strips or convex pieces, and bodies cut into the cells of a grid: GeoMesh2, Mesh2, GeoMesh3, Mesh3, MeshKind, MeshOptions, MeshPlacement3, GeoCellGrid3, GeoCell3, CellOptions3, CellAxis, GridAlignment
GeometryHelper.Packing boxes onto sheets of paper: SheetPacker, Sheet, PackOptions, PackResult
GeometryHelper.Export shapes written as OBJ, SVG and WKT: ObjWriter, SvgWriter, Wkt
GeometryHelper.Dxf DXF files read into shapes (DxfReader, DxfDocument, DxfShape), shapes written (DxfWriter), and a drawing edited with AutoCAD's classes and members, Dxf in front: DxfDatabase, its tables and records, DxfBlockTableRecord, DxfEntity and every entity class

Every operation is reachable both ways: the static form names the larger shape first, and the instance form sits on whichever of the two reads better where you are calling from.

Because both dimensions are one assembly, a flat shape in space can be laid out in its own plane, worked on with the whole 2D half of the library, and put back:

GeoCoordinateSystem3 frame = plate.GetFrame();
GeoFace2 flat = plate.ProjectToFace2(frame);
GeoFace3 back = flat.Subtract(openings)[0].ToFace3(frame);

Guides

The whole of it, searchable, with every type and member: https://nguyenthanguth.github.io/GeometryHelper/.

Guide Covers
Shared types Tolerance, Angle, the enumerations, OffsetOptions, GeometryHelperLog; reading, writing and editing DXF files, the editing with AutoCAD's classes and members; a drawing edited step by step and the points to check in AutoCAD
Geometry in the plane points to polygons and faces; extending, trimming, offsetting, combining regions
Meshing the plane triangles, grids of panels or tiles with joints and alignment, strips and convex pieces, edge to edge
Geometry in space points to solids; splitting, boolean bodies, meshes, local frames
Meshing in space flat shapes of space in panels, tiles, strips and triangles; bodies and boxes cut into blocks, bays and lifts; the cases, drawn and checked
Label placement labels placed greedily, clear of each other and of blocked regions
Packing boxes onto sheets drawing views onto A0 to A4 sheets or sheets of a size of their own, a new sheet when one is full

Coverage

dotnet test tests/GeometryHelper.UnitTest --collect:"XPlat Code Coverage"

writes a Cobertura file under TestResults. Only this library is counted.

Build and Test

dotnet build src/GeometryHelper/GeometryHelper.csproj
dotnet test  tests/GeometryHelper.UnitTest/GeometryHelper.UnitTest.csproj

Warnings are errors in CI, and every public member is documented, so a missing XML comment or a stale cref fails the build rather than landing quietly. Every example printed in the guides is also a test.

Licence

MIT. The clipping engine of Clipper2, by Angus Johnson, which is compiled into this package and resolves regions in the plane, is under the Boost Software License 1.0; THIRD-PARTY-NOTICES.md in the package holds its notice.

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.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on GeometryHelper:

Package Downloads
GeometryHelper.IfcConvert

Converts geometry between IFC (via xBIM) and GeometryHelper: points, vectors, matrices, faces, and solids.

GeometryHelper.CadConvert

Converts geometry between AutoCAD and GeometryHelper: points, vectors, lines, polylines, polygons, circles, and bounding boxes.

GeometryHelper.TeklaConvert.2025

Converts geometry between Tekla Structures 2025 and GeometryHelper: points, vectors, segments, planes, coordinate systems, bounding boxes, transformation matrices, and the faces and loops of a Tekla solid. Also reads the objects of IFC reference models into solids placed where Tekla shows them, through GeometryHelper.IfcConvert. Built for Tekla Structures 2025; install the package whose year matches your Tekla.

GeometryHelper.TeklaConvert.2020

Converts geometry between Tekla Structures 2020 and GeometryHelper: points, vectors, segments, planes, coordinate systems, bounding boxes, transformation matrices, and the faces and loops of a Tekla solid. Also reads the objects of IFC reference models into solids placed where Tekla shows them, through GeometryHelper.IfcConvert. Built for Tekla Structures 2020; install the package whose year matches your Tekla.

GeometryHelper.TeklaConvert.2026

Converts geometry between Tekla Structures 2026 and GeometryHelper: points, vectors, segments, planes, coordinate systems, bounding boxes, transformation matrices, and the faces and loops of a Tekla solid. Also reads the objects of IFC reference models into solids placed where Tekla shows them, through GeometryHelper.IfcConvert. Built for Tekla Structures 2026; install the package whose year matches your Tekla.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
13.9.0 0 11/4/2026
13.8.0 0 11/4/2026
13.7.0 0 11/4/2026
13.6.0 135 11/3/2026
13.5.0 198 11/3/2026
13.4.0 250 11/2/2026
13.3.0 250 11/2/2026
13.2.0 243 11/1/2026
13.1.0 257 10/29/2026
13.0.0 270 10/28/2026
12.3.0 264 10/23/2026
12.2.0 269 10/14/2026
12.1.0 246 10/12/2026
12.0.0 260 10/7/2026
11.2.0 243 10/6/2026
11.1.0 258 10/6/2026
11.0.1 263 10/5/2026
11.0.0 279 10/5/2026
10.0.0 272 10/3/2026
9.0.2 273 10/1/2026
Loading failed

NEW IN 13.7.0

     A minor release: one public member added, DxfDatabase.PatternSearchPath, and none removed or renamed. One fix is
     to the queries of solids far out; the rest is DXF parity with AutoCAD 2021, and the results callers will see
     change are listed under CHANGED.

     NEW, DXF
     - DxfDatabase.PatternSearchPath: folders, separated by semicolons and searched in their order, where the caller's
       own hatch pattern files are read from, as FontSearchPath gives the folders of the fonts. A HATCH given a pattern
       by SetHatchPattern is given its lines from there as AutoCAD 2021 gives them: from acadiso.pat in a drawing of
       millimetres and acad.pat in one of inches, or from a file named after the pattern, each line turned by
       PatternAngle and scaled by PatternScale and written anew when either is set, so that Explode() and
       GetHatchLinesData() draw it. ANSI31 of acadiso.pat on a square 30 by 20 holds its one line at 45 degrees and
       explodes to 11 LINEs. A file is read as AutoCAD reads one, a pattern AutoCAD refuses is refused, a pattern not
       found is left with no lines, as before, and a malformed file never throws. Every pattern of AutoCAD 2021's
       acad.pat and acadiso.pat at three scales and angles, 918 hatches, gives AutoCAD's own lines to 1E-13, and AUDIT
       finds nothing to fix. The library carries no pattern of AutoCAD's. Empty, as a drawing is opened or made,
       nothing is read and every drawing is written as before, to the byte.
     - An MTEXT of several lines is laid out in the fonts FontSearchPath finds as AutoCAD 2021 lays it out: its
       paragraphs wrapped at its width, its ActualWidth, ActualHeight and GeometricExtents, and the TEXTs Explode and a
       drawing of R12 give of it. A line breaks after the spaces between words and before or after a Chinese, Japanese
       or Korean letter, but not before a comma, a full stop or a closing bracket; a word longer than the width stays
       whole on a line of its own; spaced at least, each line stands a third of its height and a third of the MTEXT's
       height below the line before. Against AutoCAD 2021, paragraphs, widths, spacing, attachments, turns and styles
       come out as it gives them in 1 604 of 1 650 MTEXTs, breaks in 1 492 of 1 492, first and following lines in
       9 550 of 9 550, and codes and CJK letters in 789 of 789. Slanted letters, other fonts, stacks, indents and tabs
       are not measured. DxfMText.GeometricExtents is overridden; with an empty FontSearchPath nothing changes.
     - The big font of a text style (BigFontFileName) is read from FontSearchPath and its letters measured beside the
       style's SHX font as AutoCAD 2021 draws them: TEXT, ATTRIB and ATTDEF places and extents, one-line MTEXT sizes,
       multileaders landed on the right and attribute definitions in flips. A letter is read in the code page AutoCAD
       gives the big font's name (GBK for gbcbig.shx, Big5 for chineset.shx, Shift-JIS for bigfont and the extfont
       files, Korean for the four wh*.shx). Of 691 letters beside each of AutoCAD's ten CJK big fonts, all 6 910 are
       boxed as AutoCAD boxes them, and of the TEXTs in styles with a big font 15 382 of 15 450 give AutoCAD's place
       and box. On .NET the code pages need CodePagesEncodingProvider registered.

     FIXED, DXF
     - Beside a big font that is read, a TEXT stands at its bottom on the big font's depth, spaces are the big font's,
       and a TrueType style's big font, which AutoCAD does not draw, no longer leaves its TEXTs at their bottom
       unplaced: of 5 400 TEXTs of txt.shx and gbcbig.shx, 3 692 gave AutoCAD's place and box and 5 156 do.
     - DxfDatabase.SummaryInfo of a drawing of R2000 reads every custom property AutoCAD 2021 saved, and writes more
       than ten as AutoCAD does, where it read ten and refused an eleventh. A drawing of ten or fewer is written as
       before, to the byte.
     - A block given an attribute definition by DxfBlockTableRecord.AppendEntity is marked as one of attribute
       definitions (flag 2 of its BLOCK, HasAttributeDefinitions), as AutoCAD 2021 marks one, and the mark is kept when
       the definition is erased. Without it AutoCAD took a block made in code for one of no attribute: the value a
       multileader gave the block's attribute was lost, and its EXPLODE gave the INSERT no ATTRIB. These two fixes
       come of the checklist of DXF held against AutoCAD 2021, of which 23 points are settled against it.

     FIXED, solids
     - Where a point, a ray, a segment or a line stands against a solid far out is worked out near the origin, as its
       booleans and its measures are: Locate, Contains, DistanceTo, SignedDistanceTo, GetClosestPointOnBoundary and
       GetShortestLineTo of a point, and CollidesWith, DistanceTo, GetIntersections and GetShortestLineTo of a ray, a
       segment and a line, on GeoSolid3, GeoPreparedSolid3 and the shapes asked of it, move a body reaching more than
       2^20 out and more than 1 024 times the size of its box into the frame of the booleans, once, and the probe with
       it. Of 18 000 points, rays, segments and lines beside bodies ten million to a thousand million out, wrong
       answers at a hundredth, a thousandth and a millionth 209 -> 67, and 1 284 -> 9 of probes the tolerance itself
       off a face. Within a million of the origin nothing changed, to the bit. Far out the first question of a body
       takes 2 to 14 microseconds to move it; after that each takes as long as before.

     CHANGED, DXF: results callers will see change
     - Where its fonts are measured, an MTEXT of one line spaced exactly is as high as AutoCAD 2021 makes it, its
       height and a third ("ABC" of txt.shx 4 high is 5.333 high, not 4), and one whose words wrap, or that holds \T,
       \A, \L, \O, \K, \C or \~, is measured where it kept the file's 42 and 43. Reading a one-line ActualWidth with
       fonts takes 13.8 microseconds where it took 11.3 for txt.shx on .NET Framework 4.8; nothing changes without
       fonts.
     - A block given an attribute definition in code writes flag 2 in its BLOCK, where it wrote none; a block read
       from a file says what its file says.

     Details in CHANGELOG.md.

     Earlier releases: https://github.com/nguyenthanguth/GeometryHelper/blob/main/CHANGELOG.md