Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Load the threads-scad library
- include <threads-scad/threads.scad>;
- $fn = $preview ? 64:360;
- //$fn = 100; // Increase to smooth the sphere and cylinder
- // Parameters
- sphere_radius = 100; // Radius of the main sphere
- cut_percentage = 0.3; // 30% cut for Part B
- thread_depth = 150; // Depth of the thread in Part B (15 cm)
- thread_pitch = 20; // Pitch for the threads
- cylinder_height = 150; // Height of the cylinder in Part A (15 cm)
- wall_thickness = 50; // Minimum wall thickness of Part B (5 cm)
- // Bezel Threads
- bezel_diameter = 170;
- bezel_thread_length = 15;
- bezel_thread_pitch = 5;
- bezel_pipe_diameter = bezel_diameter-30;
- // Part A: Solid sphere with a cut for the threaded cylinder
- module part_A() {
- difference() {
- // Full solid sphere
- sphere(r = sphere_radius);
- // Cut off the front 30% of the sphere for Part B
- translate([0, 0, -sphere_radius * (1 - cut_percentage)])
- cylinder(h = sphere_radius * 2 * cut_percentage, r = sphere_radius + 1, center = true);
- sphere (r = sphere_radius-15);
- }
- // Add threaded cylinder petruding from spere
- translate([0, 0, -50])
- threaded_cylinder();
- }
- // Part B: Front 30% of the sphere, with an internal thread
- module part_B() {
- // Cut-away part of the sphere with internal threading
- difference() {
- // Front 30% of the sphere
- translate([0, 0, -sphere_radius * cut_percentage])
- sphere(r = sphere_radius);
- // Hollow out the inside, maintaining a 5 cm wall thickness
- translate([0, 0, -sphere_radius * cut_percentage])
- sphere(r = sphere_radius - wall_thickness);
- // Cut off the back of the bezel so that only 30% of the sphere is left
- translate([0, 0, -sphere_radius * (1 - cut_percentage)])
- cube([sphere_radius * 2, sphere_radius * 2, sphere_radius * 2], center = true);
- // Carve the threads into Part B
- translate([0, 0, 0])
- threaded_hole();
- }
- }
- // Module to create the threaded cylinder that protrudes from Part A
- module threaded_cylinder() {
- // Outer threaded cylinder
- difference() {
- RodStart(bezel_diameter, 0,bezel_thread_length,bezel_diameter,bezel_thread_pitch);
- // Hollow interior of the cylinder
- translate([0, 0, -25])
- cylinder(h = 50, r = bezel_pipe_diameter/2, center = false);
- }
- }
- // Module to create internal threads in Part B
- module threaded_hole() {
- RodEnd(bezel_diameter+20,bezel_thread_length,bezel_thread_length,bezel_diameter,bezel_thread_pitch);
- }
- // Render the final model
- translate([-150, 0, 0]) part_A(); // Move Part A to the left
- translate([150, 0, 0]) part_B(); // Move Part B to the right
- //module RodStart(diameter, height, thread_len=0, thread_diam=0, thread_pitch=0)
- translate([70, -10, 0])
- RodStart(bezel_diameter, 0,bezel_thread_length,bezel_diameter,bezel_thread_pitch);
- translate([250, 20, 0])
- RodEnd(bezel_diameter+20,bezel_thread_length,bezel_thread_length,bezel_diameter,bezel_thread_pitch);
Advertisement
Add Comment
Please, Sign In to add comment