Skip to content

Instantly share code, notes, and snippets.

@arnholm arnholm/sweep_holes.md
Last active Jan 22, 2019

Embed
What would you like to do?
// AngelCAD code. Sweep a profile with holes along a path

shape2d@ profile_with_holes()
{
   rectangle outer(100,100,center:true);  // outer border
   
   rectangle rl(65,10,center:true); // long rect. hole
   shape2d@ rl1   = rotate_z(deg:0)*translate(0,-40)*rl;
   shape2d@ rl2   = rotate_z(deg:90)*translate(0,-40)*rl;
   shape2d@ rl3   = rotate_z(deg:180)*translate(0,-40)*rl;
   shape2d@ rl4   = rotate_z(deg:270)*translate(0,-40)*rl;
   
   rectangle rs(25,10,center:true); // short rect. hole
   shape2d@ rs1   = rotate_z(deg:45)*translate(0,-20)*rs;
   shape2d@ rs2   = rotate_z(deg:135)*translate(0,-20)*rs;
   shape2d@ rs3   = rotate_z(deg:225)*translate(0,-20)*rs;
   shape2d@ rs4   = rotate_z(deg:315)*translate(0,-20)*rs;

   // compute & return final profile
   return outer - (rl1 + rl2 + rl3 + rl4) 
                - (rs1 + rs2 + rs3 + rs4) 
                - rectangle(10,10,center:true);
}

shape@ main_shape()
{
   array<pos3d@> p = { pos3d(0,0,0), pos3d(0,0,30), pos3d(25,20, 200) };
   array<vec3d@> v = { vec3d(0,1,0), vec3d(0.1,1,0), vec3d(0.3,1,0) };
   spline_path@ path = spline_path(p,v);
   return sweep(profile_with_holes(),path);
}

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