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 <module_gridfinity.scad>
include <module_lip.scad>
show_gridfinity_demo = false;
if(show_gridfinity_demo){
grid_block($fn=64);
translate([50,0,0])
union(){
frame_cavity($fn=64);
translate([0,50*3,0])
frame_cavity(remove_bottom_taper=true,$fn=64);
translate([0,50*4,0])
frame_cavity(reducedWallHeight=1,$fn=64);
}
translate([150,0,0])
union(){
pad_oversize($fn=64);
translate([0,50,0])
pad_oversize(extend_down=5,$fn=64);
translate([0,50*2,0])
pad_oversize(margins=1,$fn=64);
translate([0,50*3,0])
pad_oversize(remove_bottom_taper=true,$fn=64);
translate([0,50*4,0])
pad_oversize(render_top=false,$fn=64);
translate([0,50*5,0])
pad_oversize(render_bottom=false,$fn=64);
}
}
// basic block with cutout in top to be stackable, optional holes in bottom
// start with this and begin 'carving'
//grid_block();
module grid_block(
num_x=1,
num_y=2,
num_z=2,
position = "zero",
filledin = "disabled", //[disabled, enabled, enabledfilllip]
wall_thickness = 1.2,
cupBase_settings = CupBaseSettings(),
lip_settings = LipSettings(),
help)
{
lipHeight = 3.75;
assert_openscad_version();
cupBase_settings = ValidateCupBaseSettings(cupBase_settings);
//Legacy variables.
magnet_size=cupBase_settings[iCupBase_MagnetSize];
screw_size=cupBase_settings[iCupBase_ScrewSize];
hole_overhang_remedy=cupBase_settings[iCupBase_HoleOverhangRemedy];
box_corner_attachments_only = cupBase_settings[iCupBase_CornerAttachmentsOnly];
half_pitch=cupBase_settings[iCupBase_HalfPitch];
flat_base=cupBase_settings[iCupBase_FlatBase];
center_magnet_size = cupBase_settings[iCupBase_CenterMagnetSize];
magnet_easy_release = cupBase_settings[iCupBase_MagnetEasyRelease];
outer_size = [env_pitch().x - gf_tolerance, env_pitch().y - gf_tolerance]; // typically 41.5
block_corner_position = [outer_size.x/2 - gf_cup_corner_radius, outer_size.y/2 - gf_cup_corner_radius]; // need not match center of pad corners
magnet_position = calculateAttachmentPositions(magnet_size[iCylinderDimension_Diameter], screw_size[iCylinderDimension_Diameter]);
overhang_fix = hole_overhang_remedy > 0 && magnet_size[iCylinderDimension_Diameter] > 0 && screw_size[iCylinderDimension_Diameter] > 0 ? hole_overhang_remedy : 0;
overhang_fix_depth = 0.3; // assume this is enough
tz(env_pitch().z*num_z-fudgeFactor*2)
if(filledin == "enabledfilllip"){
color(env_colour(color_topcavity))
tz(-fudgeFactor)
hull()
cornercopy(block_corner_position, num_x, num_y)
cylinder(r=gf_cup_corner_radius, h=lipHeight);
} else {
cupLip(
num_x = num_x,
num_y = num_y,
lipStyle = lip_settings[iLipStyle],
wall_thickness = wall_thickness,
lip_notches = lip_settings[iLipNotch],
lip_top_relief_height = lip_settings[iLipTopReliefHeight],
lip_top_relief_width = lip_settings[iLipTopReliefWidth],
lip_clip_position = lip_settings[iLipClipPosition],
lip_non_blocking = lip_settings[iLipNonBlocking]);
}
translate(gridfinityRenderPosition(position,num_x,num_y))
difference() {
baseHeight = 5;
intersection() {
//Main cup outer shape
color(env_colour(color_cup))
tz(-fudgeFactor)
hull()
cornercopy(block_corner_position, num_x, num_y)
cylinder(r=gf_cup_corner_radius, h=env_pitch().z*num_z);
union(){
if(flat_base == FlatBase_rounded){
basebottomRadius = let(fbr = cupBase_settings[iCupBase_FlatBaseRoundedRadius])
fbr == -1 ? gf_cup_corner_radius/2 : fbr;
color(env_colour(color_cup))
translate([0.25,0.25,0])
roundedCube(
x = num_x*env_pitch().x-0.5,
y = num_y*env_pitch().y-0.5,
z = env_pitch().z,
size=[],
topRadius = 0,
bottomRadius = basebottomRadius,
sideRadius = gf_cup_corner_radius,
centerxy = false,
supportReduction_z = [cupBase_settings[iCupBase_FlatBaseRoundedEasyPrint],0]
);
} else {
// logic for constructing odd-size grids of possibly half-pitch pads
color(env_colour(color_base))
pad_grid(num_x, num_y, half_pitch, flat_base = flat_base, cupBase_settings[iCupBase_MinimumPrintablePadSize]);
}
color(env_colour(color_cup))
tz(baseHeight)
cube([env_pitch().x*num_x, env_pitch().y*num_y, env_pitch().z*num_z]);
}
}
if(center_magnet_size[iCylinderDimension_Diameter]){
//Center Magnet
for(x =[0:1:num_x-1])
{
for(y =[0:1:num_y-1])
{
color(env_colour(color_basehole))
translate([
x * env_pitch().x + env_pitch().x / 2, // Add half pitch in X
y * env_pitch().y + env_pitch().y / 2, // Add half pitch in Y
-fudgeFactor
])
cylinder(h=center_magnet_size[iCylinderDimension_Height]-fudgeFactor, d=center_magnet_size[iCylinderDimension_Diameter]);
}
}
}
color(env_colour(color_basehole))
tz(-fudgeFactor)
gridcopycorners(num_x, num_y, magnet_position, box_corner_attachments_only){
rdeg =
$gcci[2] == [ 1, 1] ? 90 :
$gcci[2] == [-1, 1] ? 180 :
$gcci[2] == [-1,-1] ? -90 :
$gcci[2] == [ 1,-1] ? 0 : 0;
rotate([0,0,rdeg-45+(magnet_easy_release==MagnetEasyRelease_outer ? 0 : 180)])
MagnetAndScrewRecess(
magnetDiameter = magnet_size[iCylinderDimension_Diameter],
magnetThickness = magnet_size[iCylinderDimension_Height]+0.1,
screwDiameter = screw_size[iCylinderDimension_Diameter],
screwDepth = screw_size[iCylinderDimension_Height],
overhangFixLayers = overhang_fix,
overhangFixDepth = overhang_fix_depth,
easyMagnetRelease = magnet_easy_release != MagnetEasyRelease_off);
}
}
HelpTxt("grid_block",[
"num_x",num_x
,"num_y",num_y
,"num_z",num_z
,"magnet_size",magnet_size
,"screw_size",screw_size
,"position",position
,"hole_overhang_remedy",hole_overhang_remedy
,"half_pitch",half_pitch
,"box_corner_attachments_only",box_corner_attachments_only
,"flat_base",flat_base
,"lipSettings",lip_settings
,"filledin",filledin]
,help);
}