[OpenSCAD] question on my code

Jerry Davis jdawgaz at gmail.com
Wed Apr 15 18:29:22 EDT 2015

I have a module, called cylhole, which creates a cylinder with a hole in it.
If I call it by itself, it works like I want it to.
If I call it in a difference() it somehow leaves the hole filled.

I am not sure why, and what could I do to do what I really want to do.

Here is the code:

$fn = 60;

// driver gear diameter = 16.32 mm
// driven gear bottom diameter = 45.42 mm
// driven gear top diameter = 13.55 mm
// top layer = 3.15 mm on top of bottom layer

// bottom layer has driver gear and bottom driven gear
// top layer has rack and top driver gear

cube_l = 88;
cube_w = 60;
cube_h = 5;

module cylhole(r=3, h=3, hole=1) {
  difference() {
    cylinder(r=r, h=h, center=true);
    cylinder(r=hole, h=h+1, center=true);

module bottom(r1=3, r2=3, foclen=9, nr=0) {
  fl = (cube_l/8) + (foclen/2) + nr;
  fr = (cube_l/8) - (foclen/2) + nr;

  difference() {
    cube([cube_l, cube_w, cube_h], center=true);
    translate([fl, 0, 2]) color("Aqua") cylhole(r=r1, h=cube_h, hole=1,
    translate([fr, 0, 2]) color("Blue") cylhole(r=r2, h=cube_h, hole=1,

// this doesn't ... hmm.
bottom(r1=16.32/2, r2=45.42/2, foclen=28, nr=7);

// this does what I think it should do
translate([0, cube_w+20, 0]) cylhole(12, 5, 2);


Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Arduino developer

*The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov

*f you give someone a program, you will frustrate them for a day; if you
teach them how to program, you will frustrate them for a lifetime. *-

*If writing good code requires very little comments, then writing really
excellent code requires no comments at all!*- Ken Thompson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20150415/700cbc2e/attachment-0002.html>

More information about the Discuss mailing list