Search code examples
openscad

Best practice for setting the holes required for attaching an external module


I'm new in OpenSCAD.

I have a board on which I want to attach a stepper. For this I need 5 holes in the board - one for the shaft and 4 for the screws. I draw the board and the holes in the main scad-file and use the stepper as a module. My problem is, whenever I want to replace the stepper, I have to replace the holes. Is there a good practice for this? Currently I've defined the holes in the stepper-module file as an independent module.


Solution

  • You can define holes inside of your stepper module, add an extra parameter to it, indicating if it should produce the stepper itself or the mounting holes.

    stepper(holes=false);
    difference(){board(); stepper(holes=true);}
    

    Another trick you can do subtract holes from children() inside of the stepper module. and use it like:

    stepper() { board(); }