#1158 coding style

master
Marius Kintel 2015-03-05 10:38:35 -05:00
parent 981aad9966
commit 1152e9a167
14 changed files with 119 additions and 136 deletions

View File

@ -7,15 +7,14 @@ module B() offset(0.5) text("B", size=10, halign="center", valign="center", font
$fn=64;
module GEB() {
intersection()
{
intersection() {
linear_extrude(height = 20, convexity = 3, center=true) B();
rotate([90, 0, 0])
linear_extrude(height = 20, convexity = 3, center=true) E();
linear_extrude(height = 20, convexity = 3, center=true) E();
rotate([90, 0, 90])
linear_extrude(height = 20, convexity = 3, center=true) G();
linear_extrude(height = 20, convexity = 3, center=true) G();
}
}

View File

@ -14,8 +14,7 @@ module example006()
}
}
difference()
{
difference() {
cube(100, center = true);
for (rot = [ [0, 0, 0], [1, 0, 0], [0, 1, 0] ]) {
rotate(90, rot)
@ -33,9 +32,12 @@ module example006()
[ 0, 90, [ [-25, -25], [0, 0], [+25, +25] ] ],
[ 0, -90, [ [-25, -25], [+25, -25], [-25, +25], [+25, +25] ] ]
]) {
rotate(i[0], [0, 0, 1]) rotate(i[1], [1, 0, 0]) translate([0, -50, 0])
for (j = i[2])
translate([j[0], 0, j[1]]) sphere(10);
rotate(i[0], [0, 0, 1])
rotate(i[1], [1, 0, 0])
translate([0, -50, 0])
for (j = i[2]) {
translate([j[0], 0, j[1]]) sphere(10);
}
}
}
}

View File

@ -1,18 +1,17 @@
module cutout()
{
intersection()
{
intersection() {
rotate(90, [1, 0, 0])
translate([0, 0, -50])
linear_extrude(height = 100, convexity = 1)
import(file = "example007.dxf", layer = "cutout1");
translate([0, 0, -50])
linear_extrude(height = 100, convexity = 1)
import(file = "example007.dxf", layer = "cutout1");
rotate(90, [0, 0, 1])
rotate(90, [1, 0, 0])
translate([0, 0, -50])
linear_extrude(height = 100, convexity = 2)
import(file = "example007.dxf", layer = "cutout2");
rotate(90, [1, 0, 0])
translate([0, 0, -50])
linear_extrude(height = 100, convexity = 2)
import(file = "example007.dxf", layer = "cutout2");
}
}
@ -22,10 +21,8 @@ module clip()
// NB! We have to use the deprecated module here since the "dorn"
// layer contains an open polyline, which is not yet supported
// by the import() module.
rotate_extrude(
file = "example007.dxf",
layer="dorn",
convexity = 3);
rotate_extrude(file = "example007.dxf",
layer="dorn", convexity = 3);
for (r = [0, 90])
rotate(r, [0, 0, 1])
cutout();
@ -34,36 +31,31 @@ module clip()
module cutview()
{
difference()
{
difference()
{
translate([0, 0, -10])
clip();
difference() {
difference() {
translate([0, 0, -10]) clip();
rotate(20, [0, 0, 1])
rotate(-20, [0, 1, 0])
translate([18, 0, 0])
cube(30, center = true);
translate([18, 0, 0])
cube(30, center = true);
}
# render(convexity = 5) intersection()
{
# render(convexity = 5) intersection() {
translate([0, 0, -10])
clip();
rotate(20, [0, 0, 1])
rotate(-20, [0, 1, 0])
translate([18, 0, 0])
cube(30, center = true);
translate([18, 0, 0])
cube(30, center = true);
}
}
}
echo(version=version());
translate([0, 0, -10])
clip();
translate([0, 0, -10]) clip();
// cutview();

View File

@ -1,34 +1,31 @@
echo(version=version());
difference()
{
intersection()
{
difference() {
intersection() {
translate([ -25, -25, -25])
linear_extrude(height = 50, convexity = 3)
import(file = "example008.dxf", layer = "G");
linear_extrude(height = 50, convexity = 3)
import(file = "example008.dxf", layer = "G");
rotate(90, [1, 0, 0])
translate([ -25, -125, -25])
linear_extrude(height = 50, convexity = 3)
import(file = "example008.dxf", layer = "E");
translate([ -25, -125, -25])
linear_extrude(height = 50, convexity = 3)
import(file = "example008.dxf", layer = "E");
rotate(90, [0, 1, 0])
translate([ -125, -125, -25])
linear_extrude(height = 50, convexity = 3)
import(file = "example008.dxf", layer = "B");
translate([ -125, -125, -25])
linear_extrude(height = 50, convexity = 3)
import(file = "example008.dxf", layer = "B");
}
intersection()
{
intersection() {
translate([ -125, -25, -26])
linear_extrude(height = 52, convexity = 1)
import(file = "example008.dxf", layer = "X");
linear_extrude(height = 52, convexity = 1)
import(file = "example008.dxf", layer = "X");
rotate(90, [0, 1, 0])
translate([ -125, -25, -26])
linear_extrude(height = 52, convexity = 1)
import(file = "example008.dxf", layer = "X");
translate([ -125, -25, -26])
linear_extrude(height = 52, convexity = 1)
import(file = "example008.dxf", layer = "X");
}
}

View File

@ -10,15 +10,13 @@ fanrot = dxf_dim(file = "example009.dxf", name = "fanrot");
import(file = "example009.dxf", layer = "body");
% for (z = [+(bodywidth/2 + platewidth/2),
-(bodywidth/2 + platewidth/2)])
{
-(bodywidth/2 + platewidth/2)]) {
translate([0, 0, z])
linear_extrude(height = platewidth, center = true, convexity = 10)
import(file = "example009.dxf", layer = "plate");
linear_extrude(height = platewidth, center = true, convexity = 10)
import(file = "example009.dxf", layer = "plate");
}
intersection()
{
intersection() {
linear_extrude(height = fanwidth, center = true, convexity = 10, twist = -fanrot)
import(file = "example009.dxf", layer = "fan_top");
@ -26,7 +24,7 @@ intersection()
// layer contains an open polyline, which is not yet supported
// by the import() module.
rotate_extrude(file = "example009.dxf", layer = "fan_side",
origin = fan_side_center, convexity = 10);
origin = fan_side_center, convexity = 10);
}
// Written by Clifford Wolf <clifford@clifford.at> and Marius

View File

@ -5,14 +5,11 @@
echo(version=version());
intersection()
{
surface(file = "example010.dat",
center = true, convexity = 5);
intersection() {
surface(file = "example010.dat", center = true, convexity = 5);
rotate(45, [0, 0, 1])
surface(file = "example010.dat",
center = true, convexity = 5);
surface(file = "example010.dat", center = true, convexity = 5);
}
// Written by Clifford Wolf <clifford@clifford.at> and Marius

View File

@ -2,11 +2,11 @@
echo(version=version());
difference()
{
difference() {
sphere(20);
translate([ -2.92, 0.5, +20 ]) rotate([180, 0, 180])
translate([ -2.92, 0.5, +20 ])
rotate([180, 0, 180])
import("example012.stl", convexity = 5);
}

View File

@ -1,15 +1,14 @@
echo(version=version());
intersection()
{
intersection() {
linear_extrude(height = 100, center = true, convexity= 3)
import(file = "example013.dxf");
rotate([0, 90, 0])
linear_extrude(height = 100, center = true, convexity= 3)
import(file = "example013.dxf");
linear_extrude(height = 100, center = true, convexity= 3)
import(file = "example013.dxf");
rotate([90, 0, 0])
linear_extrude(height = 100, center = true, convexity= 3)
import(file = "example013.dxf");
linear_extrude(height = 100, center = true, convexity= 3)
import(file = "example013.dxf");
}
// Written by Clifford Wolf <clifford@clifford.at> and Marius

View File

@ -1,17 +1,14 @@
module shape()
{
difference()
{
translate([ -35, -35 ]) intersection()
{
difference() {
translate([ -35, -35 ]) intersection() {
union() {
difference() {
square(100, true);
square(50, true);
}
translate([ 50, 50 ])
square(15, true);
translate([ 50, 50 ]) square(15, true);
}
rotate(45) translate([ 0, -15 ]) square([ 100, 30 ]);
}
@ -19,8 +16,7 @@ module shape()
rotate(-45) scale([ 0.7, 1.3 ]) circle(5);
}
import(file = "example009.dxf", layer = "body",
convexity = 6, scale=2);
import(file = "example009.dxf", layer = "body", convexity = 6, scale=2);
}
echo(version=version());

View File

@ -7,8 +7,7 @@ module blk1() {
module blk2() {
difference() {
translate([ 0, 0, 7.5 ])
cube([ 60, 28, 14 ], center = true);
translate([ 0, 0, 7.5 ]) cube([ 60, 28, 14 ], center = true);
cube([ 8, 32, 32 ], center = true);
}
}
@ -23,11 +22,12 @@ echo(version=version());
difference() {
blk1();
for (alpha = [0, 90, 180, 270]) {
rotate(alpha, [ 1, 0, 0]) render(convexity = 12)
difference() {
blk2();
chop();
}
rotate(alpha, [ 1, 0, 0])
render(convexity = 12)
difference() {
blk2();
chop();
}
}
}

View File

@ -34,8 +34,7 @@ module shape_tripod()
y5 = y3 + total_height - 3*thickness;
y6 = y5 + thickness;
union()
{
union() {
difference() {
polygon([
[ x1, y2 ], [ x2, y2 ],
@ -52,8 +51,7 @@ module shape_tripod()
translate([ x5 + thickness, y4 ]) circle(thickness);
}
translate([ x5, y1 ])
square([ boltlen - thickness, thickness*2 ]);
translate([ x5, y1 ]) square([ boltlen - thickness, thickness*2 ]);
translate([ x5 + boltlen - thickness, y2 ]) circle(thickness);
@ -73,8 +71,9 @@ module shape_inner_disc()
{
difference() {
circle(midhole + boltlen + 2*thickness + locklen2);
for (alpha = [ 0, 120, 240 ])
for (alpha = [ 0, 120, 240 ]) {
rotate(alpha) translate([ 0, midhole + boltlen + thickness + locklen2/2 ]) square([ thickness, locklen2 ], true);
}
circle(midhole + boltlen);
}
}
@ -83,8 +82,9 @@ module shape_outer_disc()
{
difference() {
circle(midhole + boltlen + inner1_to_inner2 + 2*thickness + locklen1);
for (alpha = [ 0, 120, 240 ])
for (alpha = [ 0, 120, 240 ]) {
rotate(alpha) translate([ 0, midhole + boltlen + inner1_to_inner2 + thickness + locklen1/2 ]) square([ thickness, locklen1 ], true);
}
circle(midhole + boltlen + inner1_to_inner2);
}
}
@ -97,8 +97,9 @@ module parts()
shape_inner_disc();
shape_outer_disc();
for (s = [ [1,1], [-1,1], [1,-1] ])
for (s = [ [1,1], [-1,1], [1,-1] ]) {
scale(s) translate([ tripod_x_off, -tripod_y_off ]) shape_tripod();
}
}
module exploded()
@ -106,9 +107,12 @@ module exploded()
translate([ 0, 0, total_height + 2*thickness ]) linear_extrude(height = thickness, convexity = 4) shape_inner_disc();
linear_extrude(height = thickness, convexity = 4) shape_outer_disc();
color([ 0.7, 0.7, 1 ]) for (alpha = [ 0, 120, 240 ])
rotate(alpha) translate([ 0, thickness*2 + locklen1 + inner1_to_inner2 + boltlen + midhole, 1.5*thickness ])
rotate([ 90, 0, -90 ]) linear_extrude(height = thickness, convexity = 10, center = true) shape_tripod();
color([ 0.7, 0.7, 1 ]) for (alpha = [ 0, 120, 240 ]) {
rotate(alpha)
translate([ 0, thickness*2 + locklen1 + inner1_to_inner2 + boltlen + midhole, 1.5*thickness ])
rotate([ 90, 0, -90 ])
linear_extrude(height = thickness, convexity = 10, center = true) shape_tripod();
}
}
module bottle()
@ -116,20 +120,20 @@ module bottle()
r = boltlen + midhole;
h = total_height - thickness*2;
rotate_extrude(convexity = 2)
{
rotate_extrude(convexity = 2) {
square([ r, h ]);
translate([ 0, h ])
intersection() {
square([ r, r ]);
scale([ 1, 0.7 ]) circle(r);
translate([ 0, h ]) {
intersection() {
square([ r, r ]);
scale([ 1, 0.7 ]) circle(r);
}
}
translate([ 0, h+r ])
intersection() {
translate([ 0, -r/2 ]) square([ r/2, r ]);
circle(r/2);
translate([ 0, h+r ]) {
intersection() {
translate([ 0, -r/2 ]) square([ r/2, r ]);
circle(r/2);
}
}
}
}
@ -139,23 +143,23 @@ module assembled()
translate([ 0, 0, total_height - thickness ]) linear_extrude(height = thickness, convexity = 4) shape_inner_disc();
linear_extrude(height = thickness, convexity = 4) shape_outer_disc();
color([ 0.7, 0.7, 1 ]) for (alpha = [ 0, 120, 240 ])
rotate(alpha) translate([ 0, thickness*2 + locklen1 + inner1_to_inner2 + boltlen + midhole, 0 ])
rotate([ 90, 0, -90 ]) linear_extrude(height = thickness, convexity = 10, center = true) shape_tripod();
color([ 0.7, 0.7, 1 ]) for (alpha = [ 0, 120, 240 ]) {
rotate(alpha)
translate([ 0, thickness*2 + locklen1 + inner1_to_inner2 + boltlen + midhole, 0 ])
rotate([ 90, 0, -90 ])
linear_extrude(height = thickness, convexity = 10, center = true) shape_tripod();
}
% translate([ 0, 0, thickness*2]) bottle();
}
echo(version=version());
if (mode == "parts")
parts();
if (mode == "parts") parts();
if (mode == "exploded")
exploded();
if (mode == "exploded") exploded();
if (mode == "assembled")
assembled();
if (mode == "assembled") assembled();
// Written by Clifford Wolf <clifford@clifford.at> and Marius
// Kintel <marius@kintel.net>

View File

@ -1,16 +1,15 @@
module step(len, mod)
{
for (i = [0:$children-1])
for (i = [0:$children-1]) {
translate([ len*(i - ($children-1)/2), 0, 0 ]) children((i+mod) % $children);
}
}
echo(version=version());
for (i = [1:4])
{
translate([0, -250+i*100, 0]) step(100, i)
{
for (i = [1:4]) {
translate([0, -250+i*100, 0]) step(100, i) {
sphere(30);
cube(60, true);
cylinder(r = 30, h = 50, center = true);

View File

@ -9,7 +9,6 @@ function get_cylinder_h(p) = lookup(p, [
echo(version=version());
for (i = [-100:5:+100]) {
// echo(i, get_cylinder_h(i));
translate([ i, 0, -30 ]) cylinder(r1 = 6, r2 = 2, h = get_cylinder_h(i)*3);
}

View File

@ -40,39 +40,40 @@ module spring(r1 = 100, r2 = 10, h = 100, hr = 12)
alpha2 = i2 * 360*r2/hr;
len1 = sin(acos(i1*2-1))*r2;
len2 = sin(acos(i2*2-1))*r2;
if (len1 < 0.01)
if (len1 < 0.01) {
polygon([
[ cos(alpha1)*r1, sin(alpha1)*r1 ],
[ cos(alpha2)*(r1-len2), sin(alpha2)*(r1-len2) ],
[ cos(alpha2)*(r1+len2), sin(alpha2)*(r1+len2) ]
]);
if (len2 < 0.01)
}
if (len2 < 0.01) {
polygon([
[ cos(alpha1)*(r1+len1), sin(alpha1)*(r1+len1) ],
[ cos(alpha1)*(r1-len1), sin(alpha1)*(r1-len1) ],
[ cos(alpha2)*r1, sin(alpha2)*r1 ],
]);
if (len1 >= 0.01 && len2 >= 0.01)
}
if (len1 >= 0.01 && len2 >= 0.01) {
polygon([
[ cos(alpha1)*(r1+len1), sin(alpha1)*(r1+len1) ],
[ cos(alpha1)*(r1-len1), sin(alpha1)*(r1-len1) ],
[ cos(alpha2)*(r1-len2), sin(alpha2)*(r1-len2) ],
[ cos(alpha2)*(r1+len2), sin(alpha2)*(r1+len2) ]
]);
}
}
linear_extrude(height = 100, twist = 180*h/hr,
$fn = (hr/r2)/stepsize, convexity = 5) {
$fn = (hr/r2)/stepsize, convexity = 5) {
for (i = [ stepsize : stepsize : 1+stepsize/2 ])
segment(i-stepsize, min(i, 1));
}
}
echo(version=version());
translate([ -30, 0, 0 ])
screw();
translate([ -30, 0, 0 ]) screw();
translate([ 30, 0, 0 ])
nut();
translate([ 30, 0, 0 ]) nut();
spring();