jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.58k stars 507 forks source link

OpenScad to OpenJSCAD fails #188

Open TeslaGeek opened 7 years ago

TeslaGeek commented 7 years ago

Hi, I have installed the CLI version on Mac and as far as I can tell everything is installed OK. However firstly, when I run openjscad example005.jscad from the terminal nothing happens. Secondly, the CLI does not allow me to choose an scad file from a local hard drive and thirdly if I have an openSCAD file, how I can convert it to OpenJSCAD ?

z3dev commented 7 years ago

@TeslaGeek Welcome!

The script places the converted file into the same directory as the original. So, please look inside the examples directory.

If the script executes properly then a message about the Blob export size should show in the terminal.

If you still have issue then please run ./openjscad --version I'd like to see the output, if any.

jeffkyjin commented 7 years ago

It seems, openscad to openjscad still have some problem. I have tried the code below, it failed.

“”

/ [leaf] / // (Total leaves that make up a pinecone) : totalLeafs = 150; // [10:400]

// (Average length of each leaf) : leafBaseLength = 60; // [10:200]

// (Average thichkness of each leaf) : leafThickness = 5; // [2:10]

// (Shape of leaf) : leafSides = 4; // [3:6]

// (Spikiness of leaf) : leafSpikiness = 8; // [0:20]

// (Upwards angle of leaf for printability) : leafGrade = 30; // [0:80]

/ [pinecone] /

// (Overall height of pinecone) : pineConeHeight = 120; // [10:300]

// (Spiraling angle between leaf (Phi = 137.5, Lucas = 100.0) ) : angleBetweenLeafs = 137.5;

// layer module layer(segments) {

union () {

    // Overall height of pinecone
    pineConeBase = leafBaseLength*0.15;
    cylinder(h = pineConeHeight, r1 = pineConeBase, r2 = 2, $fn=leafSides);
    cylinder(h = pineConeHeight*0.1, r1 = (pineConeBase+4), r2 = 0, $fn=leafSides);

    for ( i = [0 : segments] ) {

        seedNormal = (i/(segments-1));
        inverseSeedNormal = ((1-seedNormal) >.3) ? ((1-seedNormal)) : (.3);
        sinusoidalNormal = sin(seedNormal*90);
        inverseSinusoidalNormal = 1-sinusoidalNormal;

        baseTaper = .1;
        bottomLeafScalar = (seedNormal<baseTaper) ? (( seedNormal/baseTaper)*0.75+0.25 ) : 1;

        sizeScalar = bottomLeafScalar*inverseSeedNormal*leafThickness;

        leafWidth = 3*sizeScalar;
        leafHeight = 2*sizeScalar;

        leafBaseLengthCalculated = bottomLeafScalar*(leafBaseLength - (seedNormal*leafBaseLength));
        leafOffsetFromCenter = 0;
        leafTipLengthCalculated = leafSpikiness*inverseSeedNormal;
        leafHeightOffset = sinusoidalNormal*-pineConeHeight;

        rotate([0,0,0])
        rotate([0,90,0])
        rotate([i*angleBetweenLeafs ,0,0])
        translate([leafHeightOffset-5,0,0])
        leaf(
            width = leafWidth, 
            height = leafHeight, 
            baseLength = leafBaseLengthCalculated,
            tipLength = leafTipLengthCalculated,
            offsetFromCenter = leafOffsetFromCenter,
            seedNormal = seedNormal
        );
    }
}

}

// leaf module leaf(width, height, baseLength, tipLength, offsetFromCenter, seedNormal) { tip = tipLength; base = baseLength; rotate([0,-leafGrade,0]) // upwards angle for printing rotate([0,0,0]) // upwards angle for printing union () {

    // leaf base
    translate([0,0,offsetFromCenter])
    scale([height,width,1])
    cylinder(h = base, r1 = 0.5, r2 = 1, $fn=leafSides);

    // leaf tip
    translate([0,0,offsetFromCenter+base])
    scale([height,width,1])
    cylinder(h = tipLength, r1 = 1, r2 = 0, $fn=leafSides);

}

}

scale([1,1,1]) layer( totalLeafs );

“”