Tolerancing in OpenSCAD

Have questions or comments about Simplify3D, Slic3r, Cura, Reptier, etc? Or wondering about which CAD software to use...discuss it here...
Post Reply
davidb
Posts: 9
Joined: Fri Jun 06, 2014 4:57 pm

Tolerancing in OpenSCAD

Post by davidb » Fri Aug 29, 2014 12:37 pm

I'm trying to produce a part with depressions which will be a good fit for inserted components. I have an stl of the components that needs to fit. So far I've been using the difference operation in scad to make a component sized hole. The issue with this is that this hole will be nominally exactly the right size, but in practice too small. I need to make the hole slightly larger than the part which has to fit - i.e. add a tolerance of ~.2 mm on all faces.

They only way I can think of so far is to scale the components up slightly, but this seems messy as different dimensions will need different scaling factors, as will the different components. Ideally I'd like to just move the STL surfaces out by .2mm all round. Does anyone know of a way to achieve this? Or have any other suggestions?

Many thanks,
David

jsc
Posts: 1864
Joined: Thu Apr 10, 2014 4:00 am

Re: Tolerancing in OpenSCAD

Post by jsc » Fri Aug 29, 2014 4:25 pm

Minkowski with a small sphere. Although you should be aware that the OpenSCAD sphere() does not generate points at the +z and -z poles, so you may need to roll your own sphere if that is important, or use a cube. Also, Minkowski can be an expensive operation. You should also check out the OpenSCAD mailing list, which is active, has people on it who know OpenSCAD and its foibles very well, and are newbie friendly.

davidb
Posts: 9
Joined: Fri Jun 06, 2014 4:57 pm

Re: Tolerancing in OpenSCAD

Post by davidb » Fri Aug 29, 2014 4:54 pm

Thanks! Sounds like just the trick, but unfortunately doesn't work on imported stls. Will have to head along to the scad forum, but am also interested in ways to alter the STL pre-import. If the worst comes to the worst I can write a script to read the STL and push all the vertices out along their respective face normals, but would like to avoid this if possible.

davidb
Posts: 9
Joined: Fri Jun 06, 2014 4:57 pm

Re: Tolerancing in OpenSCAD

Post by davidb » Fri Aug 29, 2014 4:57 pm

Oops! It works after all (damn typos). Many thanks!

Dale Reed
Posts: 376
Joined: Thu Apr 10, 2014 1:39 am
Location: Cleveland Heights, Ohio USA

Re: Tolerancing in OpenSCAD

Post by Dale Reed » Fri Aug 29, 2014 6:13 pm

davidb,

More specific on the "it" that works, please? I assume you mean the Minkowski operation works on imported STLs. Is my assumption correct?
Thanks for working through this! I'll probably need it sooner rather than later...

Dale

davidb
Posts: 9
Joined: Fri Jun 06, 2014 4:57 pm

Re: Tolerancing in OpenSCAD

Post by davidb » Fri Aug 29, 2014 7:47 pm

Yes, the minkowski operation works on imported stls. It is, however painfully slow (even when using a cube rather than a sphere), so I'm pre-generating 'toleranced' stls with a stub .scad file and then using those in the final layout to speed it up somewhat.

tolerance.scad:

Code: Select all

minkowski(){
    import(filename);
    cube(tol);
}
Which I run from the command line with:

Code: Select all

openscad -o outfile.STL -D 'filename="infile.STL"' -D tol=.2 tolerance.scad
I should really write a make file to do it all for me, but that might be a project for another day.

jsc
Posts: 1864
Joined: Thu Apr 10, 2014 4:00 am

Re: Tolerancing in OpenSCAD

Post by jsc » Fri Aug 29, 2014 9:41 pm

If the STL is coming from an OpenSCAD file, you should be working with the original directly.

davidb
Posts: 9
Joined: Fri Jun 06, 2014 4:57 pm

Re: Tolerancing in OpenSCAD

Post by davidb » Sat Aug 30, 2014 12:51 am

STL is coming from a manufacturer provided .step file (converted with FreeCAD, and tidied up in meshlab). I've got about 9 different parts to integrate, and each takes about 3 mins to run through minkowski. The intermediate scading is just a way of caching the results so the final part can be modified and rebuilt in reasonable time.

Post Reply