Skip to content

Instantly share code, notes, and snippets.

@arnholm
Last active November 22, 2019 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arnholm/a8254293238b2143c4565fc179104576 to your computer and use it in GitHub Desktop.
Save arnholm/a8254293238b2143c4565fc179104576 to your computer and use it in GitHub Desktop.
// 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);
}
Display the source blob
Display the rendered blob
Raw
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