Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

80 Commits

Repository files navigation

PrimSharp

https://github.com/merklegroot/PrimSharp

A C# library for Constructive Solid Geometry

Objects are rendered to OpenSCAD code.
You can paste the rendered code into OpenSCAD and use it to generate an STL file.

OpenSCAD

You can get OpenSCAD from here:
https://openscad.org/

Notes

Dimensions use Width, Breadth, and Height. I went with "Breadth" instead of "Length" to avoid conflicts with the word "Length."

Example

Running this:

newCube().RotateZ(45).ToOpenScad();

Gives you this:

rotate([0, 0, 45])
cube([1, 1, 1], center=true);

Note that the geometry isn't translated to OpenScad until the ToOpenScad() method is called.

Getting outputs

I usually just use unit tests to retrieve outputs for a model.
This probably isn't the best use of tests, but it works.

usingPrimSharp;usingXunit;usingXunit.Abstractions;namespacePrimSharpTests{publicclassBoxTests{privatereadonlyITestOutputHelper_outputHelper;publicBoxTests(ITestOutputHelperoutputHelper)=>_outputHelper=outputHelper;[Fact]publicvoidBox_with_defaults()=>_outputHelper.WriteLine(newBox().ToOpenScad());}}

Primitives

Cube - a rectangular solid

newCube(width:3,breadth:5,height:2);

Cylinder - you know what a cylinder is.

newCylinder(radius:2,height:5);

Simple Operations

newBox(4,4,1).Subtract(newBox(2,2,1));

alt text

Projects

PrimSharp - Primitives
PrimDesign - Models created from primitives

About

A dotnet library for constructive solid geometry.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages