Skip to content

Instantly share code, notes, and snippets.

@loadedsith
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loadedsith/780068e5aac5dff82acd to your computer and use it in GitHub Desktop.
Save loadedsith/780068e5aac5dff82acd to your computer and use it in GitHub Desktop.
gcode for phone stand
/* [Basic] */
// Devices longest dimention.
device_height = 139;
// Second Longest Dimention
device_width = 67;
// Amount of "tray" for the device . Distance between bottom of device well and top of device well. Tip: Increase this to reduce angle between device width/height and device height/width offsets, or set offsets to 0 to get no overhang at all.
device_depth = 5;
//Modify the device tray opening height relative to its base height.
device_offset_height = 10;
//Modfify the device tray opening width relative to its base height.
device_offset_width = 10;
// Height of the stand portion, not including device tray
stand_height = 40;
//Cut out a whole in your stand, on the right or left side of your device. Also cuts off the edge of the device tray.
stand_cutout_side = "right"; // [left,right,none]
//Modfify the stands base height relative to the device height.
stand_offset_height = 25;
//Modfify the stands base width relative to the device width.
stand_offset_width = 25;
/* [Advanced] */
// Additional height added to the device tray's top edge
device_wall_height_offset_top = 0;
// Additional height added to the device tray's right edge
device_wall_height_offset_right = 0;
// Additional height added to the device tray's bottom edge
device_wall_height_offset_bottom = 0;
// Additional height added to the device tray's left edge
device_wall_height_offset_left = 3;
// The device tray's wall thickness.
device_wall_thickness =0.5;
// Additional height added to the stand tray's top edge
stand_height_offset_top = 0;
// Additional height added to the stand tray's right edge
stand_height_offset_right = 0;
// Additional height added to the stand tray's bottom edge
stand_height_offset_bottom = 0;
// Additional height added to the stand tray's left edge
stand_height_offset_left = 0;
//Cutout scale: 0-1,
stand_cutout_scale = 0.8;
//The cutout will be made at a shifted location, with reguards to your device width. You can increase or decrease this shift. It will be automatically inverted for left or right cutouts.
stand_cutout_shift_ratio = 0.2;
// How round are the edges in your cutout? Rounds but also adds to perimeters!
stand_cutout_roundness = 0;
// Thickness of stands walls
stand_wall_thickness = 0.5;
module trayShape(
offset,
bottomOffset,
tray_width,
tray_height,
tray_depth,
offset_width,
offset_height,
offset_top,
offset_right,
offset_bottom,
offset_left
){
// ignore variable values
//layer1
topLeft = [0, 0, 0];//0//[hidden]
topMiddle = [0, tray_width / 2, 0];//1//[hidden]
topRight = [0, tray_width, 0];//2//[hidden]
middleRight = [tray_height / 2,tray_width, 0];//3//[hidden]
bottomRight = [tray_height, tray_width,0];//4//[hidden]
bottomMiddle = [tray_height, tray_width / 2, 0];//5//[hidden]
bottomLeft = [tray_height, 0, 0];//6//[hidden]
middleLeft = [tray_height / 2, 0, 0];//7//[hidden]
centerHeight = offset_height / 2;
centerWidth = offset_width / 2;
ot = offset_top;
or = offset_right;
ob = offset_bottom;
ol = offset_left;
//layer2//[hidden]
l2TopLeft = [0 - centerHeight, 0 - centerWidth, tray_depth + max(ot, ol)];//8//[hidden]
l2TopRight = [0 - centerHeight, tray_width + centerWidth, tray_depth + max(ot, or)];//9//[hidden]
l2BottomRight = [tray_height + centerHeight+ ob + or, tray_width + centerWidth, tray_depth + max(ob, or)];//10//[hidden]
l2BottomLeft = [tray_height + centerHeight+ ob + ol, 0 - centerWidth, tray_depth + max(ob, ol)];//11//[hidden]
//top
tl = 0;//[hidden]
tr = 1;//[hidden]
br = 2;//[hidden]
bl = 3;//[hidden]
l2tl = 4;//[hidden]
l2tr = 5;//[hidden]
l2br = 6;//[hidden]
l2bl = 7;//[hidden]
polyhedron(
points=[
[topLeft[0] + offset, topLeft[1] + offset, topLeft[2] + bottomOffset],
[topRight[0] + offset, topRight[1] - offset, topRight[2] + bottomOffset],
[bottomRight[0] - offset, bottomRight[1] - offset, bottomRight[2] + bottomOffset],
[bottomLeft[0] - offset, bottomLeft[1] + offset, bottomLeft[2] + bottomOffset],
[l2TopLeft[0] + offset, l2TopLeft[1] + offset, l2TopLeft[2] + bottomOffset],
[l2TopRight[0] + offset, l2TopRight[1] - offset, l2TopRight[2] + bottomOffset],
[l2BottomRight[0] - offset, l2BottomRight[1] - offset, l2BottomRight[2] + bottomOffset],
[l2BottomLeft[0] - offset, l2BottomLeft[1] + offset, l2BottomLeft[2] + bottomOffset]],
triangles = [
[tl,bl,tr], [br,tr,bl], //base
[tl,tr, l2tr, l2tl], //top wall
[l2br, l2tr, tr, br],//right wall
[l2br, br, bl, l2bl],//bottom wall
[l2tl, l2bl, bl, tl],//left wall
[l2tr, l2br, l2tl], [l2br, l2bl, l2tl]//top
]);
}
module tray(
wall,
floor,
tray_width,
tray_height,
tray_depth,
offset_width,
offset_height,
offset_top,
offset_right,
offset_bottom,
offset_left,
tray_cutout
){
//If it is right, set the offset for right, if its not set it for left
potental_offset = tray_cutout == "right" ? wall * 2 : -wall * 2;
//If it is none, set the offset to 0, if its not none, it must be whatever it is above.
tray_offset = tray_cutout == "none" ? 0 : potental_offset;
//tray_offset = 0.6;
difference(){
trayShape(
0, 0.1,
tray_width, tray_height, tray_depth,
offset_width, offset_height,
offset_top,
offset_right,
offset_bottom,
offset_left
);
translate([0,tray_offset,0])
trayShape(
wall, stand_wall_thickness,
tray_width, tray_height, tray_depth,
(offset_width), (offset_height),
offset_top,
offset_right,
offset_bottom,
offset_left
);
};
}
module cenderedCube(width, height, thickness){
translate([-0.5 * height, -0.5 * width, -0.5 * thickness])
cube([height, width, thickness]);
}
module stand(height, left, right, top, bottom, stand_wall_thickness){
union(){
translate([-0.5 * device_height, -0.5 * device_width, height])
tray(
device_wall_thickness, device_wall_thickness,
device_width, device_height, device_depth,
device_offset_width, device_offset_height,
device_wall_height_offset_top,
device_wall_height_offset_right,
device_wall_height_offset_bottom,
device_wall_height_offset_left,
stand_cutout_side
);
translate([0.5 * device_height, -0.5 * device_width, 0])
rotate([0, 180, 0])
translate([0, 0, -height-device_wall_thickness])
tray(
stand_wall_thickness, device_wall_thickness,
device_width, device_height, stand_height,
stand_offset_width, stand_offset_height,
stand_height_offset_top,
stand_height_offset_right,
stand_height_offset_bottom,
stand_height_offset_left,
"none"
);
};
}
module cutout(
width, height, depth,
offsetWidth, offsetHeight, offsetDepth,
roundness
){
maximumStandOffset = max(stand_height_offset_top, stand_height_offset_right, stand_height_offset_bottom, stand_height_offset_left);
translate([
-0.5 * width + offsetWidth,
-0.5 * height + offsetHeight,
offsetDepth - maximumStandOffset]
)
minkowski(){
cube([width, height, depth + maximumStandOffset]);
cylinder(r=roundness, h=1);
}
}
module easyGrabStand(cutoutSide){
if (cutoutSide == "none") {
stand(stand_height,
stand_height_offset_top, stand_height_offset_right,
stand_height_offset_bottom, stand_height_offset_left,
stand_wall_thickness);
} else {
if (cutoutSide == "left") {
difference(){
stand(stand_height,
stand_height_offset_top, stand_height_offset_right,
stand_height_offset_bottom, stand_height_offset_left,
stand_wall_thickness
);
cutout(
stand_cutout_scale * device_height, stand_cutout_scale * device_width, stand_height,
0, device_width * -stand_cutout_shift_ratio, 0.1 + device_wall_thickness,
stand_cutout_roundness);
}
intersection(){
translate([0.5*device_height, -0.5 * device_width, 0])
rotate([0, 180, 0])
translate([0, 0, -stand_height - device_wall_thickness - stand_wall_thickness])
trayShape(
stand_wall_thickness, stand_wall_thickness,
device_width, device_height, stand_height,
(stand_offset_width), (stand_offset_height),
stand_height_offset_top,
stand_height_offset_right,
stand_height_offset_bottom,
stand_height_offset_left,
"none"
);
difference(){
cutout(
stand_cutout_scale * device_height,
stand_cutout_scale * device_width,
stand_height + 10,
0, device_width * -stand_cutout_shift_ratio, 0,
stand_cutout_roundness
);
cutout(
stand_cutout_scale * device_height - (stand_wall_thickness * 2),
stand_cutout_scale * device_width - (stand_wall_thickness * 2),
stand_height + 10,
0, device_width * -stand_cutout_shift_ratio, 0,
stand_cutout_roundness
);
}
}
} else {
difference(){
stand(stand_height,
stand_height_offset_top, stand_height_offset_right,
stand_height_offset_left, stand_height_offset_bottom,
stand_wall_thickness
);
cutout(
stand_cutout_scale * device_height, stand_cutout_scale * device_width, stand_height,
0, device_width * stand_cutout_shift_ratio, 0.1 + device_wall_thickness,
stand_cutout_roundness);
}
intersection(){
translate([0.5*device_height, -0.5 * device_width, 0])
rotate([0, 180, 0])
translate([0, 0, -stand_height - device_wall_thickness - stand_wall_thickness])
trayShape(
stand_wall_thickness, stand_wall_thickness,
device_width, device_height, stand_height,
(stand_offset_width), (stand_offset_height),
stand_height_offset_top,
stand_height_offset_right,
stand_height_offset_bottom,
stand_height_offset_left,
"none"
);
difference(){
cutout(
stand_cutout_scale * device_height, stand_cutout_scale * device_width, stand_height+10,
0, device_width * stand_cutout_shift_ratio, 0,
stand_cutout_roundness
);
cutout(
stand_cutout_scale * device_height - (stand_wall_thickness * 2),
stand_cutout_scale * device_width - (stand_wall_thickness * 2),
stand_height + 10,
0, device_width * stand_cutout_shift_ratio, 0,
stand_cutout_roundness
);
}
}
}
}
}
easyGrabStand(stand_cutout_side);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment