// Function to create the cable gland
module cable_gland(thread_diameter, cable_diameter, thread_length, gland_length) {
    union() {
        // Main body of the gland
        cylinder(h = gland_length, d = thread_diameter + 8, center = true); // Oversized cylinder for the outer gland part
        // Create threading section
        translate([0, 0, -gland_length/2])
            threaded_part(thread_diameter, thread_length);

        // Hole for the cable
        translate([0,0,-gland_length/2])
            cable_hole(cable_diameter, gland_length + 10);
    }
}

// Function to create threading part
module threaded_part(diameter, length) {
    // Simple cylinder for threading part
    cylinder(h = length, d = diameter, center = false);
}

// Function to create the cable hole
module cable_hole(diameter, hole_length) {
    difference() {
        cylinder(h = hole_length, d = diameter, center = false);
    }
}

// Example parameters for an M20 gland
cable_gland(
    thread_diameter = 20,  // Thread diameter (M20)
    cable_diameter = 10,   // Assume a cable diameter of 10mm
    thread_length = 10,    // Thread length of 10mm
    gland_length = 30      // Total length of the gland
);