Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
92b14870fThis file is pinned to the selected release. Download the original to open it in your design tool.
// include instead of use, so we get the pitch
include <gridfinity_constants.scad>
include <module_gridfinity.scad>
iAllowConnectorsFront = 0;
iAllowConnectorsBack = 1;
iAllowConnectorsLeft = 2;
iAllowConnectorsRight = 3;
show_frame_connector_demo = false;
if(show_frame_connector_demo){
$fn = 64;
translate([0,0,0]) {
ClippedWall(fullIntersection = true);
translate([15,0,0])
ClipConnector(fullIntersection=true);
translate([30,0,0])
ClipCutter(fullIntersection=true);
}
translate([0,15,0]) {
ClippedWall(straightIntersection = true);
translate([15,0,0])
ClipConnector(straightIntersection = true);
translate([30,0,0])
ClipCutter(straightIntersection = true);
}
translate([0,30,0]) {
ClippedWall(cornerIntersection = true);
//translate([15,0,0])
//ClipConnector(cornerIntersection = true);
translate([30,0,0])
ClipCutter(cornerIntersection = true);
}
translate([0,45,0]) {
ClippedWall(straightWall = true);
translate([15,0,0])
ClipConnector(straightWall = true);
translate([30,0,0])
ClipCutter(straightWall = true);
}
}
module frame_connectors(
width = 1,
depth = 1,
connectorPosition = "both",
connectorClipEnabled = false,
connectorClipSize = 10,
connectorClipTolerance = 0.1,
connectorButterflyEnabled = false,
connectorButterflySize = [5,3,2],
connectorButterflyRadius = 0.5,
connectorButterflyTolerance = 0.1,
connectorFilamentEnabled = false,
connectorFilamentLength = 10,
connectorFilamentDiameter = 2) {
if(connectorButterflyEnabled || connectorFilamentEnabled || connectorClipEnabled){
union(){
if(env_help_enabled("debug")) echo("baseplate", gci=$gci, gc_size=$gc_size, gc_is_corner=$gc_is_corner, gc_position=$gc_position, width=width, depth=depth);
if(connectorPosition == "center_wall" || connectorPosition == "both")
PositionCellCenterConnector(
left=$gci.x==0&&$gc_size.x==1&&$gc_size.y==1 && $allowConnectors[iAllowConnectorsLeft],
right=$gci.x>=$gc_count.x-1&&$gc_size.x==1&&$gc_size.y==1 && $allowConnectors[iAllowConnectorsRight],
front=$gci.y==0&&$gc_size.x==1&&$gc_size.y==1 && $allowConnectors[iAllowConnectorsFront],
back=$gci.y>=$gc_count.y-1&&$gc_size.x==1&&$gc_size.y==1&& $allowConnectors[iAllowConnectorsBack]) {
if($preview)
*rotate([0,0,90])
cylinder_printable(h=10,r=1);
if(connectorClipEnabled)
ClipCutter(size=connectorClipSize,
height= 0.8, //height of bevel1_top
frameHeight = 4,
clearance = connectorClipTolerance,
cornerRadius = gf_cup_corner_radius,
straightWall=true);
if(connectorButterflyEnabled)
translate([0,0,-$frameBaseHeight])
rotate([0,0,90])
ButterFlyConnector(
size=connectorButterflySize,
r=connectorButterflyRadius,
clearance = connectorButterflyTolerance,
taper=false,half=false);
if(connectorFilamentEnabled)
translate([0,0,-$frameBaseHeight/2])
FilamentCutter(
l=connectorFilamentLength,
d=connectorFilamentDiameter);
}
if(connectorPosition == "intersection" || connectorPosition == "both")
PositionCellCornerConnector(
left=$gci.x==0&&$gc_size.x==1&&$gc_size.y==1,
right=$gci.x>=$gc_count.x-1 && $gc_size.x==1&&$gc_size.y==1,
front=$gci.y==0&&$gc_size.x==1&&$gc_size.y==1,
back=$gci.y>=$gc_count.y-1&&$gc_size.x==1&&$gc_size.y==1) {
if($preview)
*rotate([0,0,90])
cylinder_printable(h=$corner ? 20 : 15,r=2);
if(connectorClipEnabled)
rotate([0,0,270])
ClipCutter(size=connectorClipSize,
height= 0.8, //height of bevel1_top
frameHeight = 4,
clearance = connectorButterflyTolerance,
cornerRadius = gf_cup_corner_radius,
straightIntersection = !$corner,
cornerIntersection = $corner);
if(connectorButterflyEnabled && !$corner)
translate([0,0,-$frameBaseHeight])
rotate([0,0,90])
ButterFlyConnector(
size=connectorButterflySize,
r=connectorButterflyRadius,
clearance = connectorButterflyTolerance,
taper=false,half=false);
if(connectorFilamentEnabled && !$corner)
translate([0,0,-$frameBaseHeight/2])
FilamentCutter(
l=connectorFilamentLength,
d=connectorFilamentDiameter);
}
}
}
}
module PositionCellCenterConnector(left, right,front,back){
if(left)
translate([0,env_pitch().y/2,0])
children();
if(right)
translate([env_pitch().x,env_pitch().y/2,0])
rotate([0,0,180])
children();
if(front)
translate([env_pitch().x/2,0,0])
rotate([0,0,90])
children();
if(back)
translate([env_pitch().x/2,env_pitch().y,0])
rotate([0,0,270])
children();
}
module PositionCellCornerConnector(left, right, front, back){
if(left || right || front || back)
{
if(left && front) {
if($allowConnectors[iAllowConnectorsLeft] && $allowConnectors[iAllowConnectorsFront])
let($corner = true)
rotate([0,0,90])
children();
let($corner = false){
if($allowConnectors[iAllowConnectorsFront])
translate([env_pitch().x,0,0])
rotate([0,0,90])
children();
if($allowConnectors[iAllowConnectorsLeft])
translate([0,env_pitch().y,0])
children();
}
}
if(left && back) {
if($allowConnectors[iAllowConnectorsLeft] && $allowConnectors[iAllowConnectorsBack])
let($corner = true)
translate([0,env_pitch().y,0])
children();
let($corner = false) {
if($allowConnectors[iAllowConnectorsLeft])
children();
if($allowConnectors[iAllowConnectorsBack])
translate([env_pitch().x,env_pitch().y,0])
rotate([0,0,270])
children();
}
}
if(right && front){
if($allowConnectors[iAllowConnectorsRight] && $allowConnectors[iAllowConnectorsFront])
let($corner = true)
translate([env_pitch().x,0,0])
rotate([0,0,180])
children();
let($corner = false) {
if($allowConnectors[iAllowConnectorsFront])
rotate([0,0,90])
children();
if($allowConnectors[iAllowConnectorsRight])
translate([env_pitch().x,env_pitch().y,0])
rotate([0,0,180])
children();
}
}
if(right && back){
if($allowConnectors[iAllowConnectorsRight] && $allowConnectors[iAllowConnectorsBack])
let($corner = true)
translate([env_pitch().x,env_pitch().y,0])
rotate([0,0,270])
children();
let($corner = false) {
if($allowConnectors[iAllowConnectorsRight])
translate([env_pitch().x,0,0])
rotate([0,0,180])
children();
if($allowConnectors[iAllowConnectorsBack])
translate([0,env_pitch().y,0])
rotate([0,0,270])
children();
}
}
if(left && !back && !front && !front && $gci.y<=$gc_count.y-3 && $allowConnectors[iAllowConnectorsLeft]){
$corner = false;
translate([0,env_pitch().y,0])
children();
}
if(front && !left && !right && $gci.x<=$gc_count.x-3 && $allowConnectors[iAllowConnectorsFront]){
$corner = false;
translate([env_pitch().x,0,0])
rotate([0,0,90])
children();
}
if(right && !back && !front && $gci.y<=$gc_count.y-3 && $allowConnectors[iAllowConnectorsRight]){
$corner = false;
translate([env_pitch().x,env_pitch().y,0])
rotate([0,0,180])
children();
}
if(back && !left && !right && $gci.x<=$gc_count.x-3 && $allowConnectors[iAllowConnectorsBack]){
$corner = false;
translate([env_pitch().x,env_pitch().y,0])
rotate([0,0,270])
children();
}
}
}
module FilamentCutter(
l = 5,
d = 1.75){
translate([-fudgeFactor, 0,0])
rotate([90,0,90])
cylinder_printable(h=l,d=d);
}
module cylinder_printable(h=10,r=1,d,center=false){
r = is_num(d) ? d/2 : r;
d=2*r;
flat_top_width = d/2.5;
flat_top_height = d/2+0.5;
translate(center ? [0,0,0] : [0,0,h/2])
hull(){
//Printable Cylinder
cylinder(h=h,d=d, center=true);
translate([-flat_top_width/2,d/2-flat_top_height,-h/2])
cube([flat_top_width,flat_top_height,h]);
}
}
//What is to be removed from the baseplate, to make room for the corner clip
module ClipCutter(
size=10,
height= 0.8, //height of bevel1_top
frameHeight = 4,
clippedWallThickness = 2,
clippedWallHeight = 1.6,
clearance = 0.1,
cornerRadius = gf_cup_corner_radius,
straightWall = false,
straightIntersection = false,
cornerIntersection = false,
fullIntersection = false){
height = height-clearance/2;
translate([0,0,height+fudgeFactor])
difference(){
if(straightIntersection) {
translate([-size/2-clearance,-fudgeFactor,0])
cube(size=[size+clearance*2,size/2+clearance+fudgeFactor,frameHeight-height+fudgeFactor]);
} else if(cornerIntersection) {
translate([-fudgeFactor,-fudgeFactor,0])
cube(size=[size/2+fudgeFactor+clearance,size/2+clearance+fudgeFactor,frameHeight-height+fudgeFactor]);
} else {
translate([-size/2-clearance,-size/2-clearance,0])
cube(size=[size+clearance*2,size+clearance*2,frameHeight-height+fudgeFactor]);
}
//clipped inner wall
translate([0,0,-fudgeFactor])
ClippedWall(
clipSize=size+clearance*2,
cornerRadius = cornerRadius,
clippedWallThickness = clippedWallThickness,
clippedWallHeight = clippedWallHeight-clearance,
straightWall = straightWall,
straightIntersection = straightIntersection,
cornerIntersection = cornerIntersection,
fullIntersection = fullIntersection);
}
}
module ClipConnector(
size=10,
height= 0.8, //height of bevel1_top
frameHeight = 4,
clippedWallThickness = 2,
clippedWallHeight = 1.6,
clearance = 0.1,
cornerRadius = gf_cup_corner_radius,
straightWall = false,
straightIntersection = false,
fullIntersection = false){
render()
difference(){
translate([
-size/2,
straightIntersection ? 0 : -size/2,
0])
cube(size=[size,
straightIntersection ? size/2 : size,
frameHeight-height]);
if(!straightWall) {
translate([-env_pitch().x,-env_pitch().y,-height])
frame_cavity(
num_x=2,
num_y=2);
} else {
translate([-env_pitch().x,-env_pitch().y/2,-height])
frame_cavity(
num_x=2,
num_y=1);
}
//clipped inner wall
translate([0,0,-fudgeFactor])
ClippedWall(
clipSize=size,
cornerRadius = cornerRadius,
clippedWallThickness = clippedWallThickness+clearance,
clippedWallHeight = clippedWallHeight+clearance,
straightWall = straightWall,
straightIntersection = straightIntersection,
fullIntersection = fullIntersection);
}
}
//The wall that is ls left once the clip shape is removed
module ClippedWall(
clipSize=10,
cornerRadius = gf_cup_corner_radius,
clippedWallHeight = 2,
clippedWallThickness = 1,
frameWallHeight = 1.6,
straightWall = false,
straightIntersection = false,
cornerIntersection = false,
fullIntersection = false){
corners = straightWall ? 0
: cornerIntersection ? 1
: straightIntersection ? 2
: 4;
height = clippedWallHeight+fudgeFactor;
clipRadius = cornerRadius - clippedWallThickness/2;
xlength = straightWall ? 0
: cornerIntersection ? clipSize/2+fudgeFactor
: clipSize+fudgeFactor*2;
ylength = cornerIntersection || straightIntersection? clipSize/2+fudgeFactor
: clipSize+fudgeFactor*2;
union(){
rotate([0,0,180])
translate([-clippedWallThickness/2,-clipSize/2-fudgeFactor,0])
cube(size=[clippedWallThickness,ylength,height]);
rotate([0,0,180])
translate([-clipSize/2-fudgeFactor,-clippedWallThickness/2,0])
cube(size=[xlength,clippedWallThickness,height]);
}
if(corners > 0)
difference(){
if(cornerIntersection){
translate([-(+clippedWallThickness)/2,-(clippedWallThickness)/2,0])
cube(size=[clipRadius+clippedWallThickness,clipRadius+clippedWallThickness,height]);
} else if (straightIntersection){
translate([-(clipRadius*2+clippedWallThickness)/2,-(clippedWallThickness)/2,0])
cube(size=[clipRadius*2+clippedWallThickness,clipRadius+clippedWallThickness,height]);
} else {
translate([-(clipRadius*2+clippedWallThickness)/2,-(clipRadius*2+clippedWallThickness)/2,0])
cube(size=[clipRadius*2+clippedWallThickness,clipRadius*2+clippedWallThickness,height]);
}
for(i=[0:1:corners-1]){
rotate([0,0,i*90])
translate([clippedWallThickness/2+clipRadius,clippedWallThickness/2+clipRadius,-fudgeFactor])
cylinder(r=clipRadius,h=height+fudgeFactor*2);
}
}
}
module ButterFlyConnector(
size,
r,
clearance = 0,
taper=false,
half=false)
{
h = taper ? size.y/2+size.z : size.z;
//render()
intersection(){
positions = [
[-(size.x/2-r), size.y/2-r, h/2],
[size.x/2-r, size.y/2-r, h/2],
[0, -(size.y/2-r), h/2]];
union()
for(ri = [0:half?0:1]){
mirror([0,1,0]*ri)
hull(){
for(pi = [0:len(positions)-1]){
translate(positions[pi])
cylinder(h=h,r=r,center=true);
}
}
}
if(taper)
rotate([0,90,0])
cylinder(h=size.x,r=size.y/2+size.z,$fn=4,center=true);
}
}