Skip to content

Instantly share code, notes, and snippets.

@arnholm

arnholm/fillet_plates.md

Last active Nov 22, 2019
Embed
What would you like to do?
// AngelCAD code. Demonstrate fillet between two plates
// https://arnholm.github.io/angelcad-docs/

solid@ fillet(solid@ obj, double r)
{
   // create a cube enclosing the object completely
   // with an internal void shaped by the object
   boundingbox@ box = obj.box();
   pos3d@ c  = box.center(); 
   solid@ d1 = translate(c.x(),c.y(),c.z())*cube(box.diagonal()*2,center:true) - obj;
   
   // make the void smaller
   solid@ m1 = minkowski3d(d1,sphere(r));
   //  subtract from the object
   return obj - m1;
}

shape@ main_shape()
{
   double r = 3;  // fillet radius
   
   // add fillet radius thickness on all sides of the cubes
   // since we will "machine" it away later in fillet operation
   double rth = 2*r;
   
   // bottom plate and center point
   solid@ plate = cuboid(20+rth,50+rth,2+rth);  
   pos3d@ cp    = plate.box().center(); 
   
   // extrusion and extrusion height
   solid@ extr  = cuboid(10+rth,2+rth,10+rth,center:true); 
   double eh    = extr.box().dz(); 
   
   // union the two and machine away to create fillet
   return fillet(plate+translate(cp.x(),cp.y(),cp.z()+eh/2)*extr,r);
}

void main()
{
   shape@ obj = main_shape();
   obj.write_xcsg(GetInputFullPath(),secant_tolerance:0.003);
}
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.