discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

I need to clarify scope better

BC
Bob Carlson
Sun, Jul 25, 2021 6:11 PM

I’m pretty new to OpenSCAD but I have 50+ years of programming background, so I approach OS as a programming project.

Right from the beginning I defined t (for tolerance) and t2. I guessed at .1 mm for t and that has worked perfectly for me. This has produced positive and negative spaces that fit perfectly at least for me. I have an MK3S+ and use PrusaSlicer. For a negative volume I add t or t2 and for a positive volume I subtract one of them. Obviously when a surface does not have to accommodate another, a t adjustment is not necessary. This allows me to use nominal measurements and apply the tolerances where needed. The code below demos that idea. The plug should fit snugly in the sleeve, but still rotate easily. If I use t instead of t2 as the diameter tolerance I believe I’ll get a tight but usable fit. The last difference is an example of using t to avoid the shading that occurs when a positive and negative surface coincide. Sorry, the sample uses BOSL2. I only recently started using it, but I can’t get along without it now. I think you can see why I have t AND t2 from the sample.

include <BOSL2/std.scad>;

$fn = $preview ? 45 : 120;

t = .1;
t2 = 2 * t;

iD = 5;
oD = 10;
oH = 30;
iH = 20;

module sleeve() {
difference() {
zcyl(h = oH, d = oD, anchor = DOWN);

// REMOVE
    zcyl(h = iH + t, d = iD + t2, anchor = DOWN);
}

}

module plug() {
zcyl(h = iH - t, d = iD - t2, anchor = DOWN);
}

left(20)
sleeve();

left(30)
plug();

difference() {
union() {
sleeve();
plug();
}

// REMOVE

down(t)
cube([oD + t2, oD, oH + t2], anchor = [0, 1, -1]);

}

-Bob
Tucson AZ

On Jul 24, 2021, at 15:46, Ray West raywest@raywest.com wrote:

Hi Gene,

There are a few things to think about. Forgetting the 3d printing side of things, you can't fit a two inch diameter cylinder inside a two inch diameter hole, say, no matter how you try, even if both are rounder than a round thing. The hole has to be bigger, or the cylinder smaller, or the hole a tiny bit bigger, and the cylinder a tiny bit smaller. As you know, traditionally in most engineering hard materials, then the differences are taken care of in the specified manufacturer's tolerances. For woodwork and modern glues, it is not so fussy. I reckon 3d printing is somewhere between the two, at least for the largely flexible plastics that are commonly used, and the relatively crude diy 3d printers. Couple with that, the way in which openscad, stl, and whatever slicer and firmware tries to make a round hole (or cylinder), as you have found, you will never, for example get a two inch diameter print to fit into a two inch diameter hole, or anywhere near, using metal fitting tolerances.

If you are talking about both pieces being something you are 3d printing, then I would decide on the hole diameter, and use a fudge factor to reduce that diameter for the cylinder. If the cylinder is a bit too big, it is probably easier to reduce that, rather than increasing the hole diameter. You will need different factors for different sized holes, tightness of fit, materials etc. It will take some iterations to get the right values for your fits. If you were having, say a metal bearing to fit in a hole in the 3d printed plastic, then I would use a fudge factor on the hole diameter, it's not so easy to file down the bearing.

I would keep the fudge factors outside of the modules, possibly one for each cylinder. I've put a bit of code below, to emphasize an inherent source of a bad fit

diam1 = 2;
fudge1 = 1.01;
fudge2 = 1.02; //whatever

$fn=6;  //obviously change this

module hole(d){
difference(){
cube(10,true);
translate ([0,0,-20])cylinder(60,d=d);
}
}

module  peg1(d,f1){
cylinder (50,d=d-f1);
}

  hole(diam1);
  peg1(diam1,fudge1);

translate ([20,20,0])  peg1(4,fudge2);
translate ([20,20,0]) hole(4);

On 24/07/2021 18:54, Gene Heskett wrote:

That var names within a module's {} are known only inside that module,
so its a different var within different module, even if the same name is
used in another, different module?

I would like to have all this thing fairly parametric in that changing
a "global var" before any modules are defined, changes the var for every
module that uses it, but with 3d printers having a mind of their own, I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking at
the moon?

Thanks all.

Cheers, Gene Heskett


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I’m pretty new to OpenSCAD but I have 50+ years of programming background, so I approach OS as a programming project. Right from the beginning I defined t (for tolerance) and t2. I guessed at .1 mm for t and that has worked perfectly for me. This has produced positive and negative spaces that fit perfectly at least for me. I have an MK3S+ and use PrusaSlicer. For a negative volume I add t or t2 and for a positive volume I subtract one of them. Obviously when a surface does not have to accommodate another, a t adjustment is not necessary. This allows me to use nominal measurements and apply the tolerances where needed. The code below demos that idea. The plug should fit snugly in the sleeve, but still rotate easily. If I use t instead of t2 as the diameter tolerance I believe I’ll get a tight but usable fit. The last difference is an example of using t to avoid the shading that occurs when a positive and negative surface coincide. Sorry, the sample uses BOSL2. I only recently started using it, but I can’t get along without it now. I think you can see why I have t AND t2 from the sample. include <BOSL2/std.scad>; $fn = $preview ? 45 : 120; t = .1; t2 = 2 * t; iD = 5; oD = 10; oH = 30; iH = 20; module sleeve() { difference() { zcyl(h = oH, d = oD, anchor = DOWN); // REMOVE zcyl(h = iH + t, d = iD + t2, anchor = DOWN); } } module plug() { zcyl(h = iH - t, d = iD - t2, anchor = DOWN); } left(20) sleeve(); left(30) plug(); difference() { union() { sleeve(); plug(); } // REMOVE down(t) cube([oD + t2, oD, oH + t2], anchor = [0, 1, -1]); } -Bob Tucson AZ On Jul 24, 2021, at 15:46, Ray West <raywest@raywest.com> wrote: Hi Gene, There are a few things to think about. Forgetting the 3d printing side of things, you can't fit a two inch diameter cylinder inside a two inch diameter hole, say, no matter how you try, even if both are rounder than a round thing. The hole has to be bigger, or the cylinder smaller, or the hole a tiny bit bigger, and the cylinder a tiny bit smaller. As you know, traditionally in most engineering hard materials, then the differences are taken care of in the specified manufacturer's tolerances. For woodwork and modern glues, it is not so fussy. I reckon 3d printing is somewhere between the two, at least for the largely flexible plastics that are commonly used, and the relatively crude diy 3d printers. Couple with that, the way in which openscad, stl, and whatever slicer and firmware tries to make a round hole (or cylinder), as you have found, you will never, for example get a two inch diameter print to fit into a two inch diameter hole, or anywhere near, using metal fitting tolerances. If you are talking about both pieces being something you are 3d printing, then I would decide on the hole diameter, and use a fudge factor to reduce that diameter for the cylinder. If the cylinder is a bit too big, it is probably easier to reduce that, rather than increasing the hole diameter. You will need different factors for different sized holes, tightness of fit, materials etc. It will take some iterations to get the right values for your fits. If you were having, say a metal bearing to fit in a hole in the 3d printed plastic, then I would use a fudge factor on the hole diameter, it's not so easy to file down the bearing. I would keep the fudge factors outside of the modules, possibly one for each cylinder. I've put a bit of code below, to emphasize an inherent source of a bad fit diam1 = 2; fudge1 = 1.01; fudge2 = 1.02; //whatever $fn=6; //obviously change this module hole(d){ difference(){ cube(10,true); translate ([0,0,-20])cylinder(60,d=d); } } module peg1(d,f1){ cylinder (50,d=d-f1); } hole(diam1); peg1(diam1,fudge1); translate ([20,20,0]) peg1(4,fudge2); translate ([20,20,0]) hole(4); On 24/07/2021 18:54, Gene Heskett wrote: > That var names within a module's {} are known only inside that module, > so its a different var within different module, even if the same name is > used in another, different module? > > I would like to have all this thing fairly parametric in that changing > a "global var" before any modules are defined, changes the var for every > module that uses it, but with 3d printers having a mind of their own, I > find I need some fudge1, fudge2 etc vars defined inside a module, to > fine tune sizes for a good fit. > > So is my first sentence above unconditionally true, or am I barking at > the moon? > > Thanks all. > > Cheers, Gene Heskett _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org
RD
Revar Desmera
Sun, Jul 25, 2021 6:51 PM

Back when I was designing the Snappy printable 3D printer, about six or seven years ago, I had a variable called printer_slop which worked pretty much the same. That has actually made its way into the BOSL2 library as $slop, which defaults to 0.0, but the user can set to what makes sense for their printer.

I found that $slop was often not needed for the XY accuracy of the printer, but instead for the slight layer staggering caused by a sloppy Z axis.

-Revar

On Jul 25, 2021, at 11:11 AM, Bob Carlson bob@rjcarlson.com wrote:

I’m pretty new to OpenSCAD but I have 50+ years of programming background, so I approach OS as a programming project.

Right from the beginning I defined t (for tolerance) and t2. I guessed at .1 mm for t and that has worked perfectly for me. This has produced positive and negative spaces that fit perfectly at least for me. I have an MK3S+ and use PrusaSlicer. For a negative volume I add t or t2 and for a positive volume I subtract one of them. Obviously when a surface does not have to accommodate another, a t adjustment is not necessary. This allows me to use nominal measurements and apply the tolerances where needed. The code below demos that idea. The plug should fit snugly in the sleeve, but still rotate easily. If I use t instead of t2 as the diameter tolerance I believe I’ll get a tight but usable fit. The last difference is an example of using t to avoid the shading that occurs when a positive and negative surface coincide. Sorry, the sample uses BOSL2. I only recently started using it, but I can’t get along without it now. I think you can see why I have t AND t2 from the sample.

include <BOSL2/std.scad>;

$fn = $preview ? 45 : 120;

t = .1;
t2 = 2 * t;

iD = 5;
oD = 10;
oH = 30;
iH = 20;

module sleeve() {
difference() {
zcyl(h = oH, d = oD, anchor = DOWN);

// REMOVE
     zcyl(h = iH + t, d = iD + t2, anchor = DOWN);
 }

}

module plug() {
zcyl(h = iH - t, d = iD - t2, anchor = DOWN);
}

left(20)
sleeve();

left(30)
plug();

difference() {
union() {
sleeve();
plug();
}

 // REMOVE
 
 down(t)
 cube([oD + t2, oD, oH + t2], anchor = [0, 1, -1]);

}

<Image 7-25-21 at 10.58.jpg>

-Bob
Tucson AZ

On Jul 24, 2021, at 15:46, Ray West raywest@raywest.com wrote:

Hi Gene,

There are a few things to think about. Forgetting the 3d printing side of things, you can't fit a two inch diameter cylinder inside a two inch diameter hole, say, no matter how you try, even if both are rounder than a round thing. The hole has to be bigger, or the cylinder smaller, or the hole a tiny bit bigger, and the cylinder a tiny bit smaller. As you know, traditionally in most engineering hard materials, then the differences are taken care of in the specified manufacturer's tolerances. For woodwork and modern glues, it is not so fussy. I reckon 3d printing is somewhere between the two, at least for the largely flexible plastics that are commonly used, and the relatively crude diy 3d printers. Couple with that, the way in which openscad, stl, and whatever slicer and firmware tries to make a round hole (or cylinder), as you have found, you will never, for example get a two inch diameter print to fit into a two inch diameter hole, or anywhere near, using metal fitting tolerances.

If you are talking about both pieces being something you are 3d printing, then I would decide on the hole diameter, and use a fudge factor to reduce that diameter for the cylinder. If the cylinder is a bit too big, it is probably easier to reduce that, rather than increasing the hole diameter. You will need different factors for different sized holes, tightness of fit, materials etc. It will take some iterations to get the right values for your fits. If you were having, say a metal bearing to fit in a hole in the 3d printed plastic, then I would use a fudge factor on the hole diameter, it's not so easy to file down the bearing.

I would keep the fudge factors outside of the modules, possibly one for each cylinder. I've put a bit of code below, to emphasize an inherent source of a bad fit

diam1 = 2;
fudge1 = 1.01;
fudge2 = 1.02; //whatever

$fn=6;  //obviously change this

module hole(d){
difference(){
cube(10,true);
translate ([0,0,-20])cylinder(60,d=d);
}
}

module  peg1(d,f1){
cylinder (50,d=d-f1);
}

   hole(diam1);
   peg1(diam1,fudge1);

 translate ([20,20,0])  peg1(4,fudge2);
 translate ([20,20,0]) hole(4);

On 24/07/2021 18:54, Gene Heskett wrote:
That var names within a module's {} are known only inside that module,
so its a different var within different module, even if the same name is
used in another, different module?

I would like to have all this thing fairly parametric in that changing
a "global var" before any modules are defined, changes the var for every
module that uses it, but with 3d printers having a mind of their own, I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking at
the moon?

Thanks all.

Cheers, Gene Heskett


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Back when I was designing the Snappy printable 3D printer, about six or seven years ago, I had a variable called printer_slop which worked pretty much the same. That has actually made its way into the BOSL2 library as $slop, which defaults to 0.0, but the user can set to what makes sense for their printer. I found that $slop was often not needed for the XY accuracy of the printer, but instead for the slight layer staggering caused by a sloppy Z axis. -Revar > On Jul 25, 2021, at 11:11 AM, Bob Carlson <bob@rjcarlson.com> wrote: > > I’m pretty new to OpenSCAD but I have 50+ years of programming background, so I approach OS as a programming project. > > Right from the beginning I defined t (for tolerance) and t2. I guessed at .1 mm for t and that has worked perfectly for me. This has produced positive and negative spaces that fit perfectly at least for me. I have an MK3S+ and use PrusaSlicer. For a negative volume I add t or t2 and for a positive volume I subtract one of them. Obviously when a surface does not have to accommodate another, a t adjustment is not necessary. This allows me to use nominal measurements and apply the tolerances where needed. The code below demos that idea. The plug should fit snugly in the sleeve, but still rotate easily. If I use t instead of t2 as the diameter tolerance I believe I’ll get a tight but usable fit. The last difference is an example of using t to avoid the shading that occurs when a positive and negative surface coincide. Sorry, the sample uses BOSL2. I only recently started using it, but I can’t get along without it now. I think you can see why I have t AND t2 from the sample. > > include <BOSL2/std.scad>; > > $fn = $preview ? 45 : 120; > > t = .1; > t2 = 2 * t; > > iD = 5; > oD = 10; > oH = 30; > iH = 20; > > module sleeve() { > difference() { > zcyl(h = oH, d = oD, anchor = DOWN); > > // REMOVE > zcyl(h = iH + t, d = iD + t2, anchor = DOWN); > } > } > > module plug() { > zcyl(h = iH - t, d = iD - t2, anchor = DOWN); > } > > left(20) > sleeve(); > > left(30) > plug(); > > difference() { > union() { > sleeve(); > plug(); > } > > // REMOVE > > down(t) > cube([oD + t2, oD, oH + t2], anchor = [0, 1, -1]); > } > > > <Image 7-25-21 at 10.58.jpg> > > -Bob > Tucson AZ > > > > On Jul 24, 2021, at 15:46, Ray West <raywest@raywest.com> wrote: > > Hi Gene, > > There are a few things to think about. Forgetting the 3d printing side of things, you can't fit a two inch diameter cylinder inside a two inch diameter hole, say, no matter how you try, even if both are rounder than a round thing. The hole has to be bigger, or the cylinder smaller, or the hole a tiny bit bigger, and the cylinder a tiny bit smaller. As you know, traditionally in most engineering hard materials, then the differences are taken care of in the specified manufacturer's tolerances. For woodwork and modern glues, it is not so fussy. I reckon 3d printing is somewhere between the two, at least for the largely flexible plastics that are commonly used, and the relatively crude diy 3d printers. Couple with that, the way in which openscad, stl, and whatever slicer and firmware tries to make a round hole (or cylinder), as you have found, you will never, for example get a two inch diameter print to fit into a two inch diameter hole, or anywhere near, using metal fitting tolerances. > > If you are talking about both pieces being something you are 3d printing, then I would decide on the hole diameter, and use a fudge factor to reduce that diameter for the cylinder. If the cylinder is a bit too big, it is probably easier to reduce that, rather than increasing the hole diameter. You will need different factors for different sized holes, tightness of fit, materials etc. It will take some iterations to get the right values for your fits. If you were having, say a metal bearing to fit in a hole in the 3d printed plastic, then I would use a fudge factor on the hole diameter, it's not so easy to file down the bearing. > > I would keep the fudge factors outside of the modules, possibly one for each cylinder. I've put a bit of code below, to emphasize an inherent source of a bad fit > > > diam1 = 2; > fudge1 = 1.01; > fudge2 = 1.02; //whatever > > $fn=6; //obviously change this > > module hole(d){ > difference(){ > cube(10,true); > translate ([0,0,-20])cylinder(60,d=d); > } > } > > module peg1(d,f1){ > cylinder (50,d=d-f1); > } > > hole(diam1); > peg1(diam1,fudge1); > > translate ([20,20,0]) peg1(4,fudge2); > translate ([20,20,0]) hole(4); > >> On 24/07/2021 18:54, Gene Heskett wrote: >> That var names within a module's {} are known only inside that module, >> so its a different var within different module, even if the same name is >> used in another, different module? >> >> I would like to have all this thing fairly parametric in that changing >> a "global var" before any modules are defined, changes the var for every >> module that uses it, but with 3d printers having a mind of their own, I >> find I need some fudge1, fudge2 etc vars defined inside a module, to >> fine tune sizes for a good fit. >> >> So is my first sentence above unconditionally true, or am I barking at >> the moon? >> >> Thanks all. >> >> Cheers, Gene Heskett > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org