AI로 유사한 모델 찾기
프로필 출력(0)
모델 파일(0)
게시일:2026-05-08 01:33:40
0
0
Generated from AI in to OpenSCAD because I don't know how to model or CAD yet. Code below.
// OpenSCAD code for Dual Gang Light Switch Cover // Features: American Toggle Cutouts, Countersunk Screw Holes, Randomized Jitter, Alternating States // --- Dimensions for standard American dual gang plate --- plate_width = 115.8; // 4.56 inches plate_height = 114.3; // 4.5 inches plate_thickness = 3; chamfer = 1; // --- Dimensions for Standard American Toggle Cutouts --- real_switch_width = 10.5; real_switch_height = 24.0; switch_spacing = 46; // --- Keep-out Zone (Clearance for fingers) --- keepout_width = 12; keepout_height = 55; // --- Screw hole dimensions (Countersunk) --- screw_hole_dia = 3.5; // #6-32 screw shank screw_head_dia = 7.5; // Wider top for the screw head countersink_depth = 3.0; // Depth of the cone screw_spacing_v = 60.3; // Standard toggle spacing (2.375") screw_spacing_h = 46; // --- Decorative American toggle switch dimensions --- deco_switch_base_w = 4; deco_switch_base_h = 16; deco_switch_base_d = -1.2; deco_switch_lever_w = 6; deco_switch_lever_h = 14; deco_switch_lever_d = 7; deco_switch_angle = 25; // --- Randomization & Grid Settings --- grid_spacing_x = 14; grid_spacing_y = 31; position_jitter = 7.0; module base_plate() { difference() { // Main plate body hull() { translate([chamfer, chamfer, 0]) cube([plate_width - 2*chamfer, plate_height - 2*chamfer, plate_thickness]); translate([0, 0, 0]) cube([plate_width, plate_height, 1]); } // Real Switch Cutouts translate([plate_width/2 - switch_spacing/2 - real_switch_width/2, plate_height/2 - real_switch_height/2, -1]) cube([real_switch_width, real_switch_height, plate_thickness + 2]); translate([plate_width/2 + switch_spacing/2 - real_switch_width/2, plate_height/2 - real_switch_height/2, -1]) cube([real_switch_width, real_switch_height, plate_thickness + 2]); // --- Countersunk Screw Holes --- // We define the 4 positions first to avoid repeating code screw_positions = [ [plate_width/2 - screw_spacing_h/2, plate_height/2 - screw_spacing_v/2], [plate_width/2 + screw_spacing_h/2, plate_height/2 - screw_spacing_v/2], [plate_width/2 - screw_spacing_h/2, plate_height/2 + screw_spacing_v/2], [plate_width/2 + screw_spacing_h/2, plate_height/2 + screw_spacing_v/2] ]; for (pos = screw_positions) { translate([pos[0], pos[1], 0]) { // Through hole translate([0, 0, -1]) cylinder(h=plate_thickness+2, d=screw_hole_dia, $fn=30); // Countersink Cone (Top of the hole) // d1 matches hole, d2 matches head size translate([0, 0, plate_thickness - countersink_depth]) cylinder(h=countersink_depth + 0.1, d1=screw_hole_dia, d2=screw_head_dia, $fn=30); } } } } module deco_american_toggle(is_on=true) { current_angle = is_on ? deco_switch_angle : -deco_switch_angle; translate([0, 0, plate_thickness]) union() { translate([-deco_switch_base_w/2, -deco_switch_base_h/2, 0]) cube([deco_switch_base_w, deco_switch_base_h, deco_switch_base_d]); translate([0, 0, deco_switch_base_d]) rotate([current_angle, 0, 0]) hull() { translate([-deco_switch_lever_w/2, -deco_switch_lever_d/2, 0]) cube([deco_switch_lever_w, deco_switch_lever_d, 0.1]); translate([-(deco_switch_lever_w*0.6)/2, -(deco_switch_lever_d*0.6)/2, deco_switch_lever_h]) cube([deco_switch_lever_w*0.6, deco_switch_lever_d*0.6, 1]); } } } module decorative_grid() { for (ix = [0 : floor(plate_width / grid_spacing_x)]) { for (iy = [0 : floor(plate_height / grid_spacing_y)]) { nom_x = ix * grid_spacing_x + grid_spacing_x/2; nom_y = iy * grid_spacing_y + grid_spacing_y/2; jitter_x = rands(-position_jitter, position_jitter, 1, nom_x + nom_y)[0]; jitter_y = rands(-position_jitter, position_jitter, 1, nom_x * nom_y)[0]; final_x = nom_x + jitter_x; final_y = nom_y + jitter_y; is_switch_on = ((ix + iy) % 2 == 0); if (final_x > 5 && final_x < plate_width - 5 && final_y > 5 && final_y < plate_height - 5) { in_left_zone = ( final_x > plate_width/2 - switch_spacing/2 - keepout_width/2 && final_x < plate_width/2 - switch_spacing/2 + keepout_width/2 && final_y > plate_height/2 - keepout_height/2 && final_y < plate_height/2 + keepout_height/2 ); in_right_zone = ( final_x > plate_width/2 + switch_spacing/2 - keepout_width/2 && final_x < plate_width/2 + switch_spacing/2 + keepout_width/2 && final_y > plate_height/2 - keepout_height/2 && final_y < plate_height/2 + keepout_height/2 ); if (!in_left_zone && !in_right_zone) { translate([final_x, final_y, 0]) deco_american_toggle(is_on = is_switch_on); } } } } } color("white") base_plate(); color("white") decorative_grid();
