by mechadense, published

miniSageCAD by mechadense Jan 4, 2013
0 Share
Download All Files

Thing Apps Enabled

Order This Printed View All Apps


A part of these Groups

View All


miniSageCAD by mechadense is licensed under the Creative Commons - Attribution license.

Liked By

View All

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

2479Views 1251Downloads


A tool for Constructive Solid Geometry like OpenSCAD but written in Sage http://www.sagemath.org/

There is already quite some functionality in very little code.

You can (via the Jmole 3D viewer in sage) preview & turn the 3d output before saving to *.stl file. With Sage you have a fully blown computer algebra system CAS at hand. Transfinite unbounded objects can be used for construction.

Sages implicit_plot3d is not made for this purpouse so I think this is more useful for experimentation with system design than useful construction work. But I might be wrong.

In this context I like to mention
ImplicitCAD (written by Christopher Olah)
which Is ment to deliver good performance.

I started to code miniSageCAD because while trying sage it became patently obvious to me how easy It'd be to get a minimal useful CSG system.

I wanted to preserve symbolic derivability for all csg expressions (to have symbolic access to the surface normals). I found that only lambdas are symbolically derivable but those lambda expressions can not have line breaks. This makes it necessary to break more complex objects down into subfunctions. A good thing for documentation (names) but bad in that it clutteres the global namespace. Also obstucted by this is the idea to e.g. transport the positions of the edges of a cube up the csg graph accessible in e linearly-transformed way.

new in v0.04:
corrected translate
arbitrary arity union and intersection
prism rod, prism
inshell, onshell, outshell
gyroid (left & right)


Either try it via the public worksheet (note: they are currently disabled 2012-01-04)
http://www.sagenb.org/home/pub/5036/ (Gone down somewhen before 2016-06-12)
Or download it and use it within your own sage system.

If you make somthing with it please upload your results.

All Apps

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Print through a distributed network of 3D printing enthusiasts from across the US, at a fraction of the cost of the competitors. We want to change the world for the better through technology, an...

App Info Launch App

Quickly Scale, Mirror or Cut your 3D Models

App Info Launch App

3D Print a wide range of designs with Treatstock. Easy to use tools to get the perfect result. The global 3D printing network that connects you with high-quality and fast working print services nea...

App Info Launch App

Is it possible to use your minicad to export mathematical functions to .STL files? I have been painfully trying to get an open-source software which would do it.

This is exactly what miniSageCAD does. I too was frustrated to being unable to quickly turn mathematical functions into 3D printable models (The situation may have improved by now 2016-03 - I haven't checked recently).

You have to get your function into the form of an algebraic variety that is f(x,y,z)=0.
And plug it in at the end of the code (there are a few usage examples) and execute it in sage

  • Note that miniSageCAD is more of an experiment that has usable results than a real software
  • Note If you use Firefox you may need to jump through some hoops to activate and allow the java browser plugin for the live turnable 3D preview.

Be prepared for long rendering times!

  • I only did the high level composition stuff and copied the lower level export to *.stl function from some old probably unoptimized code from Christopher Olah (author of ImplicitCAD - which you may want to check out).
  • IIRC I failed at symbolically simplifying the composed functions.
  • I did not check the useless eager evaluation overhead.

That's amazing! However I downloaded it and in the text files there are no instructions like a quickstart. Since Sage has a lot of different packages and databases, I don't quite know where to start. I am still looking into it and I think I will eventually find the way, but a quick README telling these directions wouldn't be a good introduction?

When I wrote the code there where no dependencies that where manually to add.
Back then I used locally installed Sage - Now there is SageMathCloud too:
I don't know if it will work there too.

How to implement hull or smth for emulating "extrude along the curved path"? In OpenScad I can do this via


Yes convex hulls are painfully lacking.
The reason is that convex hulls are rather nontrivial:
I think todays practically used algorithms are all vertex based.

You'd have to find a general way to generate an implicit function Surf(c):={x,y,z|f_hull(x,y,z)=c} such that forall c: Surf(c)=boundary(hull(Surf1(c),surf2(c),..)) without relying on vertex based algorithms. I guess that there isn't a noniterative direct way to do that. A hull of compositioned objects (planes & tubes) like your example is even harder. Concrete example: For easier reasoning imagine the convex hull of two circles in a two dimensional room. The implicit function for a circle is a cone. You'd have to generate a "roof" from this two cones only with elementary functions (provable impossible?).

Special cases could be implemented though. And I think this (with auto case choice) is a good way to go. Sadly two arbitrary orientated circles like in your specific case will not work this way. But e.g. a truncated cone as convex hull for two spheres will. In Haskell types could carry the necessary information or monads, but in sage I see hurdles/limits.

Another (less powerful) approach for things similar to this would be to to define an implicit function by the minimal distance to an user choosen parametrically defined spacecurve x(t),y(t),z(t).