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
Tolerancing in OpenSCAD
Re: Tolerancing in OpenSCAD
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.
Re: Tolerancing in OpenSCAD
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.
Re: Tolerancing in OpenSCAD
Oops! It works after all (damn typos). Many thanks!
Re: Tolerancing in OpenSCAD
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
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
Re: Tolerancing in OpenSCAD
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:
Which I run from the command line with:
I should really write a make file to do it all for me, but that might be a project for another day.
tolerance.scad:
Code: Select all
minkowski(){
import(filename);
cube(tol);
}
Code: Select all
openscad -o outfile.STL -D 'filename="infile.STL"' -D tol=.2 tolerance.scad
Re: Tolerancing in OpenSCAD
If the STL is coming from an OpenSCAD file, you should be working with the original directly.
Re: Tolerancing in OpenSCAD
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.