General suggestions/ideas

Discussion in 'ShapeJS' started by MrNib, Apr 1, 2014.

  1. MrNib
    MrNib Well-Known Member
    It would be great if there were a cylinder element that included two radius parameters, one for each end, creating tapered cylinder. It could also be used to create a cone of finite length.
     
  2. AlanHudson
    AlanHudson Shapeways Employee Dev Team
    Sure thing. We've coded it, should be released in the next couple days.
     
  3. MrNib
    MrNib Well-Known Member
    Excellent, I''ll be using that tapered cylinder as soon as it is available.

    While I'm at it here's another question or suggestion as the case may be. Let's pretend I'm too lazy to use a third party package to combine x3db files from different scripts...

    If you wanted to output 2 identical or slightly different objects it's relatively easy to duplicate, translate the copy, and then output both at the same time using the output commands at the end of the script. As far as I can tell you just need to establish an initial grid that is large enough to contain both objects before generating the output. Is there a better way to duplicate an item in the script after the first has been output so you don't need to use an enlarged grid? I'm thinking something like that might reduce overall computation time/memory usage.

    And if you wanted to generate two wildly different sized yet related objects such that it doesn't make a lot of sense to use the same initial grid to contain both, is there a way to generate the different objects sequentially in the same script and then combine individual outputs at then end so they can be exported together into the same print file? For example, if you wanted a script to generate geometrically mismatched geometries like a long, narrow stirring stick and a big fat mug into the same output print file, what would you do?

     
  4. MrNib
    MrNib Well-Known Member
    One more thing. Why is subtraction more complicated than addition?

    If I can do this to simply add a cylinder to a structure:

    structure.add(new Cylinder(blah-blah))

    wouldn't it make sense to also have something simpler like this to subtract?:

    structure.sub(new Cylinder(blah-blah))



     
  5. AlanHudson
    AlanHudson Shapeways Employee Dev Team
    Tapered Cylinders are now available. Here is some sample code:

    function main(args) {
    var size = args[0];
    var thickness = args[1];
    var grid = createGrid(-16*MM,16*MM,-16*MM,16*MM,-16*MM,16*MM,0.1*MM);
    var cylinder = new Cylinder(new Vector3d(0,0,0), new Vector3d(0,10*MM,0),5*MM,10*MM);
    var maker = new GridMaker();
    maker.setSource(cylinder);
    maker.makeGrid(grid);
    return grid;
    }
     
  6. AlanHudson
    AlanHudson Shapeways Employee Dev Team
    Not sure I follow this example.

    To add things you use a Union operation:

    var union = new Union(foo,bar);

    or you can
    var union = new Union();
    union.add(foo);
    union.add(bar);

    To subtract you use a Subtraction operation:

    var subtract = new Subtraction(foo,bar);

    So the constructor methods are equal so perhaps your talking about chaining them together. In the union case it makes sense to union n objects together hence we have a .add() method. For subtract it's not clear what subtracting 3 things would do. if its a,b,c is that (a - b) - c?

    I could conceive of a general boolean class that did something like this:

    var bool = new Boolean().
    bool.union(a,b);
    bool.subtract(c);
    bool.union(d).

    This would be (a+b) - c + d.

    Is this the type of style your wanting?
     
  7. MrNib
    MrNib Well-Known Member
    I need to review my code again to see exactly what was causing me heartburn. It seemed as though I was creating lots of temporary unions and subtractions when all I wanted to do was something simpler like this:

    structureA = structureA - structureB

    Since I was doing additions and subtractions conditionally I was getting more confused with the defining of multiple temporary unions and subtractions. However I'm sure if I fully review my code step by step I can clean things up myself. Mostly I think it's mostly a matter structuring and ordering things better. Not a "real" software guy so I need to stare at things a bit longer to get the coding more efficient with less brute force.

    I'm probably also a victim of thinking along Tinkercad lines where an object can be a negative object so if I add a positive cube and an negative cylinder you end up with a cube with a hole cut out of it. I would imagine the main Tinkercad editor is doing something similar internally with union and subtraction definitions it's just that it's done graphically and sequentially in multiple paths with multiple discrete objects.

    Regardless though, things are working and the ShapeJS scripting is awesome!

     
  8. MrNib
    MrNib Well-Known Member


    [/quote]


    I could conceive of a general boolean class that did something like this:

    var bool = new Boolean().
    bool.union(a,b);
    bool.subtract(c);
    bool.union(d).

    This would be (a+b) - c + d.

    Is this the type of style your wanting?
    [/quote]


    After deep contemplation at the grocery store that type of boolean method could simplify things. But why even require the necessity of explicitly defining different add or subtract commands? How about something like this?

    var union = new Union();
    union.add(foo);
    union.add(-bar);

    or

    var union = new Union();
    union.add(foo - bar);

    The result in either case would be equal to "foo minus bar". Would that make any type of rational sense?
     
  9. MrNib
    MrNib Well-Known Member
    Taper!

    [​IMG]