Close



Results 1 to 10 of 16

Threaded View

  1. #14
    Super Moderator curious aardvark's Avatar
    Join Date
    Jul 2014
    Posts
    8,816
    don't forget to use 'union'

    Basically union glues everything between it's brackets into a single lump that you can then apply any of the other operations to.

    And also it's worth knowing that you can apply operations to an entire bracket set.
    Took me a while to figure that out.

    for example:
    difference(){
    translate([0,0,10]) cube([20,20,20],true);
    translate([0,0,10]) sphere(d=25);
    } // end diff
    makes my favourite torture test model. Screw benchies if you can print the hollow cube - the machine is dialled in !

    So if we want to do something to the whole model we can simply put the operation in front of the difference and it will effecdt everything between the brackets - much like making it aseperate module does. But without the extra hassle.

    rotate([45,0,0]) resize([10,40,30]) difference(){
    translate([0,0,10]) cube([20,20,20],true);
    translate([0,0,10]) sphere(d=25);
    } // end diff
    So if you've got a section in the middle oif a module you want to change all at once - slap a set of 'union' brackets round it and apply the operations to the union operation :-)

    This is particularly useful if you use a 'minkowski' command to round off corners.
    Because minkowski takes the degree of roundness form a sphere or a cylinder. It also adds all measurements together and changes the size of the model.
    So a resize command before a minkowski command will keep the model the right size and apply more or less curvature depending on the diameter of the cylinder or sphere.

    minkowski(){
    cube([20,20,20]);
    cylinder(d=5,h=1);
    } // end mink


    versus:

    resize([20,20,20]) minkowski(){
    cube([20,20,20]);
    cylinder(d=5, h=1);
    } // end mink

    I did read the explanation of how minkowski works. And it involved robots driving around rooms on different vectors and colliding with things - yeah....

    Minkowski is a fun command to play with - but it does reqquire some serious calculation - what with all those little robots driving around.
    I really need to find that 'explanation' again - it was completely surreal.

    It's amazing just how complicated you can get with simple things.

    It's also why I always mark what operation the second curly bracket applies to. Otherwise it gets really confusing, really quickly.

    It's also why i use very short variable names.
    Some calculations for parametric models can contain several sets of bracketed calculations in a single slot. If you use long names for the variables, they become almost impossibly long and damn difficult to read.

    For example, this line from a script that makes hinged moulds for clay sling glandes: translate([(gd+hod)/2+hod/2,gl/2+st,gd/2])
    Is pretty easy to read.
    but if the variables read:
    gd=glandediameter,
    hod=hingeouterdiameter
    gl=glandelength
    st=shellthickness
    It would be so bloody long the whole thing just looks like a 60's stream of consciousness novel.
    And that's just one operation in a line of script that has several, equally convoluted operartions and a shape.

    There is frequently/occasionally (delete as appropriate) method to my madness.
    Last edited by curious aardvark; 04-12-2021 at 02:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •