FWeynschenk / ppBricks

Perfect Printable Bricks
https://flwe.nl/ppBricks/
13 stars 4 forks source link

backend not working #9

Closed oschwand closed 1 year ago

oschwand commented 1 year ago

Hello,

The backend fails with an Internal Server Error (so it's not the same problem as in the other issues where the backend server was not accessible at all).

By the way, what is the licence of all that ? I would be happy to run my own backend for my personal use.

Thx

FWeynschenk commented 1 year ago

I really should containerize my backend...

Update broke a dependency, again.

FWeynschenk commented 1 year ago

in the meantime, here is the openscad file I use to actually create the stl's.

/* [Settings] */
Type = "regular"; //["regular", "technic", "plate", "arm"]
TopType = "studs"; //["studs", "tile", "techStuds"]
// Different sources specify different stud heights, these should all work.
studHeight = 1.7; //[1.6,1.7,1.8]
Width = 2; //[1:1:50]
Depth = 4; //[1:1:50]
// 9.6 is regular height, 3.2 is thin.
Height = 9.6; //[3.2:3.2:57.6]
// Technic type ignores Width/Depth/Height and uses TechLength.
TechLength = 8; //[2:100]
TechHoleAlign = "aligned"; //["aligned", "offset"]
// Arm length x
ArmLengthX = 3; //[1:100]
ArmDepth = "full"; //["full", "half"]

/* [Modifiers] */
// offset for the studs radius.
studOuterRadiusOffset = 0.0; //[-0.2:0.01:0.2]
// offset for the techStuds inner radius.
studInnerRadiusOffset = 0.0; //[-0.2:0.01:0.2]
// offset for the outer radius of the tube, the cylinders on the underside of bricks.
tubeOuterRadiusOffset = 0.0; //[-0.2:0.01:0.2]
// offset for the inner radius of the tube.
tubeInnerRadiusOffset = 0.0; //[-0.2:0.01:0.2]
// offset for the wall thickness, outside dimensions do not change.
wallThicknessOffset = 0.0; //[-0.2:0.01:0.2]
// offset for the radius of the technic holes.
techHoleRadOffset = 0.0; //[-0.2:0.01:0.2]
// offset for the radius of the arm holes.
armHoleRadOffset = 0.0; //[-0.2:0.01:0.2]

module __Customizer_Limit__ () {}
// render consts
$fn = 50;

// brick consts
u = 1.6;                // lego unit = 1.6mm.
techHeight = 9.6;       // tech bricks are standard height.
diam = 4.8;             // standard diameter of studs and holes.
rad = diam/2;           // corresponding radius because thats what built-in functions use.
tubeDiamOuter = 6.51;   // find more sources??
techHoleHeight = 5.8;   // find more sources??
techHoleLipRad = 3.2;   // 6.2/2 specified in source
hollowDepth = 2.6;      // not an official measurement, this works tho
armThickness = 7.4;  // where does this unit come from??

// util const
upright = [0,-90,0];
e = 0.001; // epsilon to prevent undefined faces

// adjusted values
studOuterRad = rad + studOuterRadiusOffset + 0.06;
studInnerRad = rad - u/2 + studInnerRadiusOffset + 0.06;
wallThickness = 1.4 + wallThicknessOffset - 0.04;
tubeRadOuter = tubeDiamOuter/2 + tubeOuterRadiusOffset;
tubeRadInner = rad + tubeInnerRadiusOffset + 0.18;
techHoleRad = rad + techHoleRadOffset + 0.15;
armHoleRad = rad + armHoleRadOffset;
armDepth = ArmDepth == "full" ? 8-0.2 : 4-0.2; 

//  FUNCTIONS
function outer(L) = L * 8 - 0.2; // 8mm per stud - 0.2 for tolerances
function sl(A, AA) = A * 8 - 4 - AA * 4;
function studLocXY(W, WW, D, DD) = [sl(W,WW), sl(D,DD), 0];
function studLocZ(H) = [0, 0, H/2+studHeight/2];
function techHoleLoc(i, L, o) = [techHoleHeight-techHeight/2, i*8-L*4-o, 0];
function armHoleLoc(i, L) = [sl(i,L), 0, 0];
function armOuter(L) = L * 8 - 0.6;

// MAIN
if(Type == "arm") {
    linear_extrude(armDepth, center=true) {
        difference() {
            square([armOuter(ArmLengthX), armThickness], center=true);
            for(i = [1:ArmLengthX]) {
                translate(armHoleLoc(i, ArmLengthX)) {
                    circle(techHoleLipRad);
                }
            }
            //rounded end 1
            translate([armOuter(ArmLengthX)/2-armThickness/2,0,0]) {
                difference() {
                    square(armThickness+e, center=true);
                    circle(armThickness/2);
                    translate([-armThickness*1/4,0,0]) {
                        square([armThickness/2+e, armThickness+e], center=true);
                    }
                }
            }
            // rounded end 2
            translate([-(armOuter(ArmLengthX)/2-armThickness/2),0,0]) {
                difference() {
                    square(armThickness+e, center=true);
                    circle(armThickness/2);
                    translate([+armThickness*1/4,0,0]) {
                            square([armThickness/2+e, armThickness+e], center=true);
                    }
                }
            }
        }
    }
    linear_extrude(armDepth-u, center=true) {
        for(i = [1:ArmLengthX]) {
            translate(armHoleLoc(i, ArmLengthX)) {
                difference() {
                    circle(techHoleLipRad);
                    circle(armHoleRad);
                }
            }
        }
    }
}
if(Type == "regular") {
    NUBBS(Width, Depth, Height);
    TUBES(Width, Depth, Height);
    difference() {
       BODY(Width, Depth, Height);
       HOLLOW(Width,Depth,Height);
    }  
}
if (Type == "technic"){
    NUBBS(1, TechLength, techHeight);
    if(TechHoleAlign == "offset") {        
        difference() {
            rotate(upright) {
                linear_extrude(outer(1), center=true) {
                    difference() {
                        square([techHeight,outer(TechLength)], center=true);
                        for(i = [1:TechLength-1]) {
                            translate(techHoleLoc(i,TechLength, 0)){
                                circle(techHoleLipRad);
                            }
                        }
                    }
                }
            }
            HOLLOW(1, TechLength, techHeight);
        }
        rotate(upright) {
            linear_extrude(outer(1) - u, center=true) {
                for(i = [1:TechLength-1]) {
                    translate(techHoleLoc(i,TechLength, 0)){
                        difference() {
                            circle(techHoleLipRad+e);
                            circle(techHoleRad);
                        }
                    }
                }
            }
        }
    } else if (TechHoleAlign == "aligned") {
        difference() {
            rotate(upright) {
                linear_extrude(outer(1), center=true) {
                    difference() {
                        square([techHeight,outer(TechLength)], center=true);
                        for(i = [1:TechLength]) {
                            translate(techHoleLoc(i,TechLength, 4)){
                                circle(techHoleLipRad);
                            }
                        }
                    }
                }
            }
            HOLLOW(1, TechLength, techHeight);
        }
        rotate(upright) {
            linear_extrude(outer(1) - u, center=true) {
                for(i = [1:TechLength]) {
                    translate(techHoleLoc(i,TechLength, 4)){
                        difference() {
                            circle(techHoleLipRad+e);
                            circle(techHoleRad);
                        }
                    }
                }
            }
        }

    }
}
if (Type == "plate") {
    NUBBS(Width, Depth, u);
    difference() {
        BODY(Width, Depth, u);
    }
}
// MODULES
module NUBBS(in_W, in_D, h) {
    if(TopType == "studs" || TopType == "techStuds") {
        translate(studLocZ(h)) {
            linear_extrude(height=studHeight, center=true) {
                for(W=[1:in_W]) {
                    for(D=[1:in_D]) {
                        translate(studLocXY(W,in_W,D,in_D)) {
                            difference() {
                                circle(studOuterRad);
                                if(TopType=="techStuds") {
                                circle(studInnerRad);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
module BODY(W, D, H) {
    cube([outer(W), outer(D), H], center=true);
}
module TUBES(W,D,H) { //internal tube for bricks with both dimensions > 1
    if(W>1&&D>1) {
        translate([0,0,-(H-hollowDepth)/2]) {
            linear_extrude(hollowDepth, center=true) {
                for(i = [1:(W-1)]) {
                    for(j = [1:D-1]) {
                        translate([i*8-W*4,j*8-D*4,0]){
                            difference() {
                                circle(tubeRadOuter);
                                circle(tubeRadInner); 
                            }
                        }
                    }
                }
            }
        }
    }
}
module HOLLOW(W,D,H) {
    translate([0,0,hollowDepth-H]){
        cube([outer(W)-wallThickness*2, outer(D)-wallThickness*2, H], center=true);
    }
}
FWeynschenk commented 1 year ago

https://openscad.org/ to use it

FWeynschenk commented 1 year ago

It should be fixed now!

oschwand commented 1 year ago

It works ! Thx for the fix and for the openscad file.