+module ExtrudeClipElevation(extra=0){
+ translate([0,
+ lock_0y + lock_d/2 + clip_d + extra,
+ -clip_ymin])
+ rotate([90,0,0])
+ linear_extrude(height= clip_d + extra*2, convexity=100)
+ children(0);
+}
+
+module ThroughHole(r, y, z, x=-50) {
+ translate([x, y, z])
+ rotate([0, 90, 0])
+ cylinder(r=r, h=100, $fn=20);
+}
+
+module MountingHoleCylinders(r, x=-50){
+ for (z=[ 1/4, 3/4 ]) {
+ rotate([0,0, backflange_angle])
+ ThroughHole( r,
+ -tube_dia/2 -0.5*backflange_d + backflange_hole_dy,
+ total_h * z,
+ x);
+ }
+}
+
+module ThroughHoles(){
+ MountingHoleCylinders(mountscrew_dia/2);
+
+ ThroughHole( clipbolt_dia/2,
+ lock_0y + lock_d/2 + clip_d/2 + front_th/2,
+ total_h - cliprecess_h - clip_th - clip_d/2 );
+}
+
+module MainPositive(){
+ difference(){
+ union(){
+ linear_extrude(height=total_h, convexity=100) MainPlan();
+ ExtrudeClipElevation() ClipElevationPositive();
+ }
+ ExtrudeClipElevation(1) ClipElevationNegative();
+ }
+}
+
+module Bracket(){ ////toplevel
+ difference(){
+ MainPositive();
+ ThroughHoles();
+ }
+}
+
+module TestTopEdge(){ ////toplevel
+ intersection(){
+ translate([0,0, -total_h])
+ translate([0,0, 4])
+ Bracket();
+ translate([-200,-200,0])
+ cube([400,400,100]);
+ }
+}
+
+module TestClipBoltHole(){ ////toplevel
+ intersection(){
+ union(){
+ translate([0, 0, -5])
+ Bracket();
+ translate([-4, lock_0y + lock_d/2 + 1, 0])
+ cube([8, 4, 1.5]);
+ }
+ translate([-200, lock_0y + lock_d/2 + 0.1])
+ cube([400, 400, total_h-20]);
+ }
+}
+
+module Demo(){ ////toplevel
+ Bracket();
+ color("blue") MountingHoleCylinders(mountscrew_dia/2 - 0.1);
+ color("black") MountingHoleCylinders(mountscrew_washer/2,
+ back_ohw + 0.25);
+}
+
+module DivideDemo(){ ////toplevel
+ color("black") translate([0,0,-2]) MainPlan();
+ color("grey") DivideInPlace() DivideHook();
+ color("blue") translate([0,0,-4]) DivideInPlace() DivideCut();
+}
+