OpenCSG.NET 1.0.6

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

OpenCSG.NET

NuGet

English | 中文

OpenCSG.NET is a Constructive Solid Geometry (CSG) library for .NET — solid primitives (Cube, Sphere, Cylinder), boolean operations (Union, Subtract, Intersect), and STL export. Zero dependencies, netstandard2.0, MIT licensed.

A manual C# port of OpenJsCad's csg.js, merged from two forks of praeclarum/Csg (via the hypar-io/Csg branch chain).

Quick Start

dotnet add package OpenCSG.NET
using Csg;
using static Csg.Solids;

// Primitives
var cube = Cube(size: 2, center: true);
var sphere = Sphere(r: 1, center: true);
var cylinder = Cylinder(r: 0.5, h: 3, center: true);

// Boolean operations
var union = Union(cube, sphere);
var difference = cube.Subtract(sphere);
var intersection = cube.Intersect(sphere);

// Transformations
var moved = cube.Translate(x: 5, y: 0, z: 0)
                .RotateZ(45)
                .Scale(0.5);

// STL export (ASCII)
using (var fs = File.Create("output.stl"))
using (var wr = new StreamWriter(fs))
{
    union.WriteStl("union", wr);
}

// STL export (binary)
using (var fs = File.Create("output.stl"))
using (var wr = new BinaryWriter(fs))
{
    union.WriteStl("union", wr);
}

Build

dotnet build OpenCSG.NET.slnx    # requires .NET 9+ SDK
dotnet test tests/OpenCSG.NET.Tests/

To build the core library with .NET 8 SDK:

dotnet build src/OpenCSG.NET/OpenCSG.NET.csproj -c Release
dotnet test tests/OpenCSG.NET.Tests/

Targets: library = netstandard2.0, tests/samples/perf = net8.0.

Upstream

OpenJsCad csg.js (JavaScript)
  └── praeclarum/Csg (manual C# port)
        └── hypar-io/Csg
              ├── Csg (origin-centering Union fix, NaN validation)
              └── DotNetCsg (binary STL, iterative BSP, RotateX/Y/Z)
                    └── OpenCSG.NET (this project — merged improvements)

OpenCSG.NET integrates Csg and DotNetCsg, taking the best from each: the origin-centering Union() fix from Csg, and binary STL output, iterative BSP tree, rotation helpers, and samples from DotNetCsg.

License

MIT. See LICENSE for the full text.


<a id="中文">中文</a>

OpenCSG.NET 是一个面向 .NET 的构造实体几何(CSG)建模库。提供基础形体(立方体、球体、圆柱体)、布尔运算(并集、差集、交集)以及 STL 文件导出。零依赖,netstandard2.0,MIT 授权。

本库是 OpenJsCad csg.js 的手工 C# 移植,合并了 praeclarum/Csg(经 hypar-io/Csg 分支链)两个 fork 的改进。

快速开始

dotnet add package OpenCSG.NET
using Csg;
using static Csg.Solids;

// 基础形体
var cube = Cube(size: 2, center: true);
var sphere = Sphere(r: 1, center: true);
var cylinder = Cylinder(r: 0.5, h: 3, center: true);

// 布尔运算
var union = Union(cube, sphere);           // 并集
var difference = cube.Subtract(sphere);    // 差集
var intersection = cube.Intersect(sphere); // 交集

// 变换
var moved = cube.Translate(x: 5, y: 0, z: 0)
                .RotateZ(45)
                .Scale(0.5);

// STL 导出 (ASCII)
using (var fs = File.Create("output.stl"))
using (var wr = new StreamWriter(fs))
{
    union.WriteStl("union", wr);
}

// STL 导出 (二进制)
using (var fs = File.Create("output.stl"))
using (var wr = new BinaryWriter(fs))
{
    union.WriteStl("union", wr);
}

构建

dotnet build OpenCSG.NET.slnx    # 需要 .NET 9+ SDK
dotnet test tests/OpenCSG.NET.Tests/

使用 .NET 8 SDK 构建核心库:

dotnet build src/OpenCSG.NET/OpenCSG.NET.csproj -c Release
dotnet test tests/OpenCSG.NET.Tests/

目标框架:核心库 = netstandard2.0,测试/示例/性能 = net8.0

上游关系

OpenJsCad csg.js (JavaScript)
  └── praeclarum/Csg (手工 C# 移植)
        └── hypar-io/Csg
              ├── Csg (Union 原点居中修复、NaN 校验)
              └── DotNetCsg (二进制 STL、迭代 BSP、RotateX/Y/Z)
                    └── OpenCSG.NET (本项目 — 合并两者改进)

OpenCSG.NET 整合了 CsgDotNetCsg,取其各自优势:来自 Csg 的 Union 原点居中修复,来自 DotNetCsg 的二进制 STL 输出、迭代 BSP 树、旋转变换辅助方法及示例。

许可证

MIT。详见 LICENSE

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

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
1.0.9 151 8/5/2026
1.0.8 111 8/3/2026
1.0.7 106 8/2/2026
1.0.6 103 7/31/2026
1.0.0 99 7/31/2026