Author Topic: Threads - ISO  (Read 115 times)


  • Newbie
  • *
  • Posts: 28
    • View Profile
Threads - ISO
« on: 2020-09-12, 15:34:18 »
I've been recently printing using pet-g. I find it has good mechanical properties for what I want, or at least better than abs or pla. It can be ground, filed and machined, without too many problems. I was thinking of using it for jigs and fixtures, clamps, etc, and was wondering about trying some rule of thumb tests. I designed a T nut, with a 12mm thread. Knowing that holes came out undersize, I changed the od to 12.2, it printed, but still a bit tight on the 12mm stud, so I ran a tap down through. I think the fit could be improved by using a 12mm od thread, as it should be, but I found it would not accept exactly 12mm. I based the code on Carsten's example. Here's my code. the '//this line' comment, was left from when I was originally going to tap a plain hole, but if it is removed, or changed to the root diameter, the code fails. I think, because of the countersinks interacting with the thread ends, it causes confusion in the rendering, changing the secant_tolerance dramatically effects the result.

Code: [Select]
// AngelCAD code.

double to_rad(double deg) { return PI*deg/180.0; } // from degrees to radians

   shape2d@ ISO_thread(double Dmaj, double pitch)
   double P = pitch;
   // basic thread profile
   double H = P*cos(to_rad(30));
   double delta = 0.01*P;

   // establish coordinates in profile
   double x1 = delta;;
   double x2 = P/8;
   double x3 = P/2 - P/16;
   double x4 = P/2 + P/16;
   double x5 = P - P/8;
   double x6 = P - delta;

   double y1 = 0;
   double y2 = H/4 - P/16;
   double y3 = H/4;
   double y4 = H - H/8;

   // build the thread profile, points CCW
   pos2d@[] points = { pos2d(x1,y1),  // p0
                       pos2d(x6,y1),  // p1
                       pos2d(x6,y2),  // p2
                       pos2d(x5,y3),  // p3
                       pos2d(x4,y4),  // p4
                       pos2d(x3,y4),  // p5
                       pos2d(x2,y3),  // p6
                       pos2d(x1,y2)   // p7
   shape2d@ profile = polygon(points);

   // put the profile in place, ready for rotation around Y
   @profile = translate(0.5*Dmaj-H+H/8,P/2)*rotate_z(deg:-90)*profile;

   return profile;
   solid@ ISO_screw(double Dmaj, double pitch)
   // EXPERIMENTAL: non-zero pitch and multiple revolutions
   // rotate profile around Y, 13 revolutions, then make it upright
   double revs = 15;
   shape2d@ thread_profile = ISO_thread(Dmaj:Dmaj,pitch:pitch);
   solid@ threads = translate(0,0,pitch*revs)*rotate_x(deg:90)*rotate_extrude(thread_profile,deg:360*revs,pitch:-pitch);

   //make a cylinder inside the threads, then cut the ends by intersecting with a large diameter cylinder

   double H = pitch*cos(to_rad(30));
   double Dmin = Dmaj + 2*(H/8 - H + 0.8*H/4);
   double Rmin = 0.5*Dmin;
   solid@ rod  = cylinder(r:Rmin,h:pitch*revs);
   solid@ screw = intersection3d(union3d(rod,threads),translate(0,0,0.5*pitch)*cylinder(h:pitch*revs*0.9,r:100));

   solid@ cutter = cone(h:pitch*revs*1.3,r1:Dmaj*1.35,r2:1);
   return translate(0,0,-5)*intersection3d(screw,cutter);

shape@ main_shape()
   // t nut with 10mm hole
   solid@ mynut = cuboid(28,22,8);
   @mynut = mynut + translate (0,4,0)*cuboid(28,14,15);
   // hole
   @mynut= mynut -translate(14,11,0)* cylinder(50,4); //this line
   solid@ bolt = ISO_screw(12.05,1.75) ;
  // add countersinks
   solid@ cs = translate(14,11,4)*cone (17.3,0,10);
   solid@ uc =  translate(14,11,-6.3)*cone(17.3,10,0);
   return mynut- translate( 14,11,0)* bolt -cs - uc;

 void main()
   shape@ obj = main_shape();
« Last Edit: 2020-09-13, 09:21:24 by Carsten Arnholm »

Carsten Arnholm

  • Administrator
  • Newbie
  • *****
  • Posts: 45
    • View Profile
Re: Threads - ISO
« Reply #1 on: 2020-09-13, 09:20:54 »
Here's my code. the '//this line' comment, was left from when I was originally going to tap a plain hole, but if it is removed, or changed to the root diameter, the code fails.

This code as shown seems to run fine. It is not clear to me what '//this line'  is referring to so I am not able to reproduce. Which line number in the script?


  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: Threads - ISO
« Reply #2 on: 2020-09-13, 14:15:35 »
Hi Carsten,
The line in my code ' @mynut= mynut -translate(14,11,0)* cylinder(50,4); //this line'
is from before I used your threading code, I was simply 'drilling' a plain hole, and tapping it when printed. I was thinking it should not be required, as I thought your code removed the core of the thread, but if that line is altered too much, or removed, then the script does not work, It also fails if the depth of countersink (the h values in the cones) is altered or the secant_tolerance value. It becomes a bit of a juggling act. It just happened that my original 12.2 od was OK, but 12.0 od  is not.

So, if you change the value for the diameter of the cylinder in ' //this line' e.g. to 5.35,  (10.7mm being  the tapping drill size for 12mm bolt), it looks OK, change to 5.355 it throws an exception, and I get other errors by altering that value. Comment out that line, then  sometimes it completes OK, sometimes a blank screen, sometimes an image with red. It seems to be almost random behavior.

This type of  problem seems to be getting quite common with what I am doing, and seem to be not too repeatable. If you do not get this happening then either, my installation is faulty, I have pc memory problems, or your version/setup is different than mine.