Skip to content

Instantly share code, notes, and snippets.

@arnholm arnholm/
Last active Jun 11, 2019

What would you like to do?

Example using boundingbox in AngelCAD.

In this example we read an external model of unknown dimensions and use bounding box to center it on the origin. AngelCAD requires a quality checked model in OBJ,OFF or AMF format, so we use the polyfix utility to first convert from STL to OBJ and heal the model at the same time.

polyfix from

Hook.stl from

polyfix Hook.stl -out=*.obj

  input_file = Hook.stl
         out = *.obj

polyhedron 0 ================= volume=4955, dtol=0.01, atol=1e-006, maxiter=10
iteration 0: vertices=17898 faces=5966
             warning: 70 zero area faces.
             warning: nonmanifold edges: uc(1)=17898 
             merged 15373 vertices
             removed 939 collapsed or zero area faces
             split 5 faces
             total changes=16317
             warning: nonmanifold edges: uc(1)=28 

iteration 1: vertices=2525 faces=5028
             warning: nonmanifold edges: uc(1)=28 
             merged 102 vertices
             removed 196 collapsed or zero area faces
             split 3 faces
             total changes=301
             warning: nonmanifold edges: uc(1)=19 

iteration 2: vertices=2423 faces=4833
             warning: nonmanifold edges: uc(1)=19 
             merged 32 vertices
             removed 55 collapsed or zero area faces
             total changes=87
             no warnings

iteration 3: vertices=2391 faces=4778
             merged 4 vertices
             removed 8 collapsed or zero area faces
             total changes=12
             no warnings

iteration 4: vertices=2387 faces=4770
             total changes=0
             no warnings

             polyhedron 0: vertices=2387 faces=4770 : no warnings

Writing: Hook.obj

... polyfix finished, time used: 0d 00h 00m 01s
// AngelCAD code.
shape@ main_shape()
   // Read the model file
   solid@ hook = polyhedron("Hook.obj");

   // use the model boundingbox to place the model centered on origin, 
   // bottom of model in XY-plane
   auto box =;
   pos3d@ c =;
   return translate(-c.x(),-c.y(),-box.p1().z())*hook;

void main()
   shape@ obj = main_shape();
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.